#include <bits/stdc++.h>
using namespace std;
void solve() {
  vector<int> a, b, c, d;
  int k1, k2, n, x, cnt = 0, num = 1000;
  cin >> n >> k1;
  for (int i = 0; i < k1; i++) cin >> x, a.push_back(x), c.push_back(x);
  cin >> k2;
  for (int i = 0; i < k2; i++) cin >> x, b.push_back(x), d.push_back(x);
  while ((c.size() > 0 && d.size() > 0) && num > 0) {
    if (c.front() > d.front() && num > 0) {
      int f = c.front(), b1 = d.front();
      d.erase(d.begin()), c.push_back(b1), c.push_back(f), c.erase(c.begin());
    } else {
      int f = c.front(), b1 = d.front();
      d.erase(d.begin()), d.push_back(f), d.push_back(b1), c.erase(c.begin());
    }
    cnt++;
    num--;
  }
  if (c.size() == 0)
    cout << cnt << " " << 2 << endl;
  else if (d.size() == 0)
    cout << cnt << " " << 1 << endl;
  else
    cout << -1 << endl;
}
int main() {
  int t = 1;
  while (t-- > 0) solve();
}
