import sys from random import randint input = lambda:sys.stdin.readline().rstrip() sys.setrecursionlimit(1007) def scc(n, edge): redge=[[]for _ in range(n)] for i in range(n): for j in edge[i]: redge[j].append(i) order=[] used=[0]*n group=[-1]*n def dfs(u): used[u]=1 for v in edge[u]: if not used[u]: dfs(v) order.append(u) def rdfs(u,c): group[u]=c used[u]=1 for v in redge[u]: if not used[v]: rdfs(v,c) for i in range(n): if not used[i]: dfs(i) used=[0]*n x=0 for u in order[::-1]: if not used[u]: rdfs(u,x) x+=1 return x,group def bipartite_graph_check(n, edge): color = [-1] * n for i in range(n): if color[i] != -1: continue stack = [i] color[i] = 0 for node in stack: for mode in edge[node]: if color[mode] == -1: stack.append(mode) color[mode] = color[node] ^ 1 elif color[mode] == color[node]: return False return True n,m=map(int,input().split()) edge=[[] for _ in range(n)] redge=[[] for _ in range(n)] edges=[[-1]*n for _ in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 redge[b].append(a) edge[a].append(b) edges[a][b]=i if bipartite_graph_check(n,edge): exit(print(-1)) label,_=scc(n,edge) if label!=1: exit(print(-1)) rg="RG" print("".join([rg[randint(0,1)] for i in range(m)]))