#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
vector<long long> a, b;
map<pair<long long, long long>, long long> mp;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k1, k2;
  cin >> n >> k1;
  for (long long i = 0; i < k1; i++) {
    long long num;
    cin >> num;
    a.push_back(num);
  }
  cin >> k2;
  for (long long i = 0; i < k2; i++) {
    long long num;
    cin >> num;
    b.push_back(num);
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  long long count = 0;
  while (count < 200) {
    if (a.empty()) {
      cout << count << " " << 2;
      return 0;
    }
    if (b.empty()) {
      cout << count << " " << 1;
      return 0;
    }
    if (a.back() > b.back()) {
      long long x = a.back();
      long long y = b.back();
      mp[{x, y}]++;
      a.pop_back();
      b.pop_back();
      a.push_back(y);
      a.push_back(x);
      reverse(a.begin(), a.end());
      reverse(a.begin() + 2, a.end());
    } else {
      long long x = a.back();
      long long y = b.back();
      mp[{x, y}]++;
      a.pop_back();
      b.pop_back();
      b.push_back(x);
      b.push_back(y);
      reverse(b.begin(), b.end());
      reverse(b.begin() + 2, b.end());
    }
    count++;
  }
  if (count > 150) {
    cout << -1;
  }
}
