#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> c;
int sum_c;

int readAns(InStream &in) {
    vector<int> v = in.readInts(sum_c, 0, 9, "v");
    vector<int> t(10);
    for (int c : v) {
        t[c]++;
    }
    for (int i = 0; i < 10; i++) {
        if (t[i] != c[i]) {
            in.quitf(_wa, "wrong number of digits");
        }
    }
    int ans = 0;
    for (int i = 0; i < sum_c; i++) {
        for (int j = i; j < sum_c; j++){
            ans += i * 10 + j;
        }
    }
    return ans;
}

int main(int argc,char* argv[]){
	registerTestlibCmd(argc,argv);

	c = inf.readInts(10,0,50,"c_i");
	sum_c = 0;
	for (int a : c) {
	    sum_c += a;
	}

	int jscore = readAns(ans);
	int pscore = readAns(ouf);

	if(jscore < pscore){
		quitf(_fail,"Jury's answer is not optimal");
	} else if(jscore > pscore){
		quitf(_wa,"Participant's answer is not optimal");
	} else {
		quitf(_ok,"OK");
	}

	return 0;
}