// Arup Guha
// 4/22/2017
// Solution for 2017 Round 1B Code Jam Problem B (large)

// This is really ugly also, because I built it piece by piece and kept on finding little issues...
// The key idea is that for the hybrids, they can only be next to one thing, so we must have enough of that
// thing to sandwich them, like "RGRGRGR". The one special case is in the sample. If we only have Rs an Gs or
// a similar case, we can have an equal number and don't need one extra of the Rs. Basically, if we meet 
// those requirements, we can do it. Then, we just create one superletter for G, O and V as shown above. When
// placing them, go every other around the circle...if you can't it's impossible.

// Btw, I guarantee there's a much nicer way to code this given that the colors were cyclicly give to us. I
// hard coded everything, which I always tell my students not to do - doh!

import java.util.*;

public class b {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();
		
		// Process all cases.
		for (int loop=1; loop<=numCases; loop++) {
			
			// Read data.
			int n = stdin.nextInt();
			int[] data = new int[6];
			for (int i=0; i<6; i++) {
				data[i] = stdin.nextInt();
			}
			
			// Screen this out.
			if (!ok(data,n)) {
				System.out.println("Case #"+loop+": IMPOSSIBLE");
			}
			
			// Solve it.
			else {
				
				// Create our items and sort the list from large to small frequency. Not sure that the sort is needed though...
				item[] list = new item[3];
				list[0] = new item("R", "G", data[0], data[3]);
				list[1] = new item("Y", "V", data[2], data[5]);
				list[2] = new item("B", "O", data[4], data[1]);
				Arrays.sort(list);
				
				// Our special case.
				if (numt(data) == 2) {
					
					// Find the pair that exists and interleave them.
					String code = "ROYGBV";
					int[] pair = new int[2];
					int j = 0;
					for (int i=0; i<6; i++) 
						if (data[i] > 0) 
							pair[j++] = i;
					
					// Here is the interleave.
					String res = "";
					for (int i=0; i<n/2; i++)
						res = res + code.charAt(pair[0]) + code.charAt(pair[1]);	
					
					// Print the result.
					System.out.println("Case #"+loop+": "+res);
				}
				
				else {
					
					// Our new number of segments, taking into account superletters.
					int nS = data[0] - data[3] + data[2] - data[5] + data[4] - data[1];
					
					// res will store the strings in our final answer.
					String[] res = new String[nS];
					Arrays.fill(res, null);
					
					// cur is where we are placing the next item.
					int cur = 0;
					boolean flag = false;
					
					// Go through all 3 colors.
					for (int z=0; z<3; z++) {
				
						// super letter case, place it first.
						if (list[z].f2 > 0) {
							
							// place it and advance 2 slots around the circle.
							res[cur] = list[z].getBig();
							cur = cur + 2;
							if (!flag && cur >= nS) {
								cur = 1;
								flag = true;
							}					
						}
						
						// Calculate the number of times we'll put in the single letter, depending on if
						// there was a super letter or not.
						int rep = list[z].f1;
						if (list[z].f2 > 0) rep = list[z].f1 - list[z].f2 - 1;	
					
						// Place them.
						for (int i=0; i<rep; i++) {
							
							// Place and advance.
							res[cur] = list[z].s;
							cur = cur + 2;
							
							// To be cyclic - there has to be a better way that this...
							if (!flag && cur >= nS) {
								cur = 1;
								flag = true;
							}
						}
										
					}
				
					// Build the answer.
					String ans = "";
					for (int i=0; i<res.length; i++)
						ans = ans + res[i];				
					
					// Print it.
					System.out.println("Case #"+loop+": "+ans);
				}
			}
		}
	}
	
	// Returns the number of positive entries in data.
	public static int numt(int[] data) {
		int res = 0;
		for (int i=0; i<data.length; i++)
			if (data[i] > 0)
				res++;
		return res;
	}
	
	// Returns if we can do it or not.
	public static boolean ok(int[] data, int n) {
		
		// Too many of one thing.
		for (int i=0; i<6; i++)
			if (2*data[i] > n)
				return false;
				
		// Not enough padding for the hybrid colors.
		if (data[4] < data[1]) return false;
		if (data[0] < data[3]) return false;
		if (data[2] < data[5]) return false;
		
		// Equality cases can't have any other colors.
		if (data[1] > 0 && data[4] == data[1] && data[1]+data[4] < n) return false;
		if (data[3] > 0 && data[0] == data[3] && data[0]+data[3] < n) return false;
		if (data[5] > 0 && data[2] == data[5] && data[2]+data[5] < n) return false;
		
		// Calculate new letter frequencies.
		int newb = data[4] - data[1];
		int newr = data[0] - data[3];
		int newg = data[2] - data[5];
		int news = newb + newr + newg;
		
		// Make sure we don't break the rules with the new letter frequencies, which account for superletters.
		if (2*newb > news) return false;
		if (2*newr > news) return false;
		if (2*newg > news) return false;
		
		// If we get here, we are good.
		return true;
	}
}

class item implements Comparable<item> {
	
	public String s;
	public String mix;
	public int f1;
	public int f2;
	
	public item(String mys, String m, int myf1, int myf2) {
		s = mys;
		mix = m;
		f1 = myf1;
		f2 = myf2;
	}
	
	// Want to place the most frequent ones first.
	public int compareTo(item other) {
		return (other.f1-other.f2) - (this.f1-this.f2);
	}
	
	// Builds our super letter.
	public String getBig() {
		String res = "";
		for (int i=0; i<f2; i++)
			res = res + s + mix;
		res = res + s;
		return res;
	}
}