#include <bits/stdc++.h>
using namespace std;
clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
void solve() {
  long long n;
  cin >> n;
  long long k1;
  cin >> k1;
  deque<long long> f, s;
  while (k1) {
    long long x;
    cin >> x;
    f.push_back(x);
    k1--;
  }
  long long k2;
  cin >> k2;
  while (k2) {
    long long x;
    cin >> x;
    s.push_back(x);
    k2--;
  }
  long long curr = 0;
  while (true) {
    curr++;
    long long ff = f.front();
    long long ss = s.front();
    s.pop_front();
    f.pop_front();
    if (ff < ss) {
      s.push_back(ff);
      s.push_back(ss);
    } else {
      f.push_back(ss);
      f.push_back(ff);
    }
    if (s.empty()) {
      cout << curr << " " << 1 << '\n';
      break;
    } else if (f.empty()) {
      cout << curr << " " << 2 << '\n';
      break;
    } else if (curr > 1000) {
      cout << -1 << '\n';
      break;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  start = clock();
  cout << fixed << setprecision(20);
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
