// Arup Guha
// 7/16/2014
// Solution to SI@UCF Week 2 Contest Problem: U Can't Finish

import java.util.*;

public class ucf {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int numCases = Integer.parseInt(stdin.nextLine().trim());

        // Process each case.
        for (int loop=0; loop<numCases; loop++)
            System.out.println(process(stdin.nextLine().trim()).equals("UCF"));
    }

    public static String process(String s) {

        // Just find each uppercase character in order in s and return.
        String ans = "";
        for (int i=0; i<s.length(); i++)
            if (Character.isUpperCase(s.charAt(i)))
                ans = ans + s.charAt(i);
        return ans;
    }
}
