#include <bits/stdc++.h>
using namespace std;
queue<int> qu1;
queue<int> qu2;
int n, k1, k2, x;
int main() {
  scanf("%d", &n);
  scanf("%d", &k1);
  for (int i = 1; i <= k1; i++) {
    scanf("%d", &x);
    qu1.push(x);
  }
  scanf("%d", &k2);
  for (int i = 1; i <= k2; i++) {
    scanf("%d", &x);
    qu2.push(x);
  }
  int cnt = 0;
  while (!qu1.empty() && !qu2.empty()) {
    int a = qu1.front(), b = qu2.front();
    qu1.pop();
    qu2.pop();
    if (a > b) {
      qu1.push(b);
      qu1.push(a);
    } else {
      qu2.push(a);
      qu2.push(b);
    }
    cnt++;
    if (cnt > 1e7) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << " ";
  if (qu1.size())
    cout << 1 << endl;
  else
    cout << 2 << endl;
  return 0;
}
