#include<iostream>#include<set>usingnamespace std;constint maxn =10010;int n, m;
set<int>s;struct{
int vex1;int vex2;}edges[maxn];int colors[maxn];intmain(){
cin >> n >> m;for(int i =0; i < m; i++){
int x, y;cin >> x >> y;edges[i]={
x,y };}int c;cin >> c;for(int i =0; i < c; i++){
s.clear();int no =0;for(int j =0; j < n; j++){
cin >> colors[j];s.insert(colors[j]);}for(int j =0; j < m; j++){
if(colors[edges[j].vex1]== colors[edges[j].vex2]){
no =1;break;}}if(no ==1)cout <<"No"<< endl;elsecout << s.size()<<"-coloring"<< endl;}return0;}