#include <iostream>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int p, q;
        string s;
        cin >> p >> q >> s;

        if (p == 1 && q == 1) {
            if (s == "on") {
                cout << "on" << endl;
            } else {
                cout << "off" << endl;
            }
        } else if (p == 0 && q == 0) {
            if (s == "off") {
                cout << "off" << endl;
            } else {
                cout << "on" << endl;
            }
        } else {
            if (p == 0 && s == "on") { 
                cout << (q == 0 ? "on" : "off") << endl; 
            } else if (p == 1 && s == "off") { 
                cout << (q == 1 ? "on" : "off") << endl; 
            } 
        }
    }

    return 0;
}