#include <bits/stdc++.h>
using namespace std;
int fac(int n) { return n < 2 ? 1 : n * fac(n - 1); }
int main() {
  int n, m1, m2, ans = 0;
  queue<int> a, b;
  cin >> n;
  cin >> m1;
  for (int i = 0; i < m1; i++) {
    int k;
    cin >> k;
    a.push(k);
  }
  cin >> m2;
  for (int i = 0; i < m2; i++) {
    int k;
    cin >> k;
    b.push(k);
  }
  int max_states = fac(n + 1);
  while (a.empty() != true && b.empty() != true) {
    if (a.front() > b.front()) {
      int popb = b.front();
      b.pop();
      a.push(popb);
      int popa = a.front();
      a.pop();
      a.push(popa);
      ans++;
    } else if (a.front() < b.front()) {
      int popa = a.front();
      a.pop();
      b.push(popa);
      int popb = b.front();
      b.pop();
      b.push(popb);
      ans++;
    }
    if (ans > max_states) {
      printf("-1\n");
      return 0;
    }
  }
  cout << ans << " ";
  if (a.empty() == true)
    cout << 2;
  else
    cout << 1;
  return 0;
}
