#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int n, x, y;
int a[N], b[N];
bool g[6][6] = {
{0, 0, 1, 1, 0},
{1, 0, 0, 1, 0},
{0, 1, 0, 0, 1},
{0, 0, 1, 0, 1},
{1, 1, 0, 0, 0}
};
int main()
{
cin >> n >> x >> y;
for (int i = 1; i <= x; i ++ ) cin >> a[i];
for (int i = 1; i <= y; i ++ ) cin >> b[i];
int socre1 = 0, socre2 = 0;
for (int i = 1; i <= n; i ++ )
{
int p = (i - 1) % x + 1, q = (i - 1) % y + 1;
p = a[p], q = b[q];
socre1 += g[p][q];
socre2 += g[q][p];
}
cout << socre1 << ' ' << socre2 << endl;
return 0;
}