一定互关az
#include <bits/stdc++.h>
using namespace std;
//a赢返回1,b赢返回2,平局返回0
inline int judge(int a, int b) {
if (a == 0) {
if (b == 0) return 0;
else if (b == 1 || b == 4) return 1;
else return 2;
} else if (a == 1) {
if (b == 1) return 0;
else if (b == 2 || b == 4) return 1;
else return 2;
} else if (a == 2) {
if (b == 2) return 0;
else if (b == 0 || b == 3) return 1;
else return 2;
} else if (a == 3) {
if (b == 3) return 0;
else if (b == 0 || b == 3) return 1;
else return 2;
} else if (a == 4) {
if (b == 4) return 0;
if (b == 2 || b == 3) return 1;
else return 2;
}
return 10;
}
int main() {
int n, na, nb, t, ans1 = 0, ans2 = 0;
cin >> n >> na >> nb;
queue <int> a;
queue <int> b;
for (int i = 1; i <= na; i++) {
cin >> t;
a.push(t);
}
for (int i = 1; i <= nb; i++) {
cin >> t;
b.push(t);
}
for (int i = 1; i <= n; i++) {
int x = a.front();
int y = b.front();
cout << x << ' ' << y << ' ' << judge(x, y) <<endl;
if (judge(x, y) == 1) ans2++;
else if (judge(x, y) == 2) ans1++;
a.pop();
b.pop();
a.push(x);
b.push(y);
}
cout << ans1 << ' ' << ans2 << endl;
return 0;
}