XYZ Encryption PROBLEM

I AM NOT GETTING WHAT ACTUALLY THIS PROBLEM WANTS TO MAKE DO .NOT GETTING ANY IDEA WHATS IS LOGIC WILL BE USED TO SOLVE THIS PROBLEM

In this question you are given an encryption method of a string which consist of only three alphabets x,y,z
the encryption method converts a string into a unique graph having nodes from 1 to n, the encryption method states that there is a edge between two nodes u and v if s[u-1]=s[v-1] (as string are 0 indexed in c++) OR s[u-1] and s[v-1] are neighbouring characters .
what we have to do is , we are given a graph and we have to tell if there is a string which can form that graph under above conditions

in sample input we are given
3 1
1 2

here ,this graph can be generated from folowing strings : xxz , zzx
thus the output is yes

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.