#include <bits/stdc++.h>
using namespace std;
int const maxn = 15;
int n, k1, k2;
int _max;
queue<int> qu1, qu2;
int main() {
  scanf("%d", &n);
  int tmp;
  _max = 1;
  for (int i = 1; i <= n; ++i) _max *= i;
  scanf("%d", &k1);
  for (int i = 1; i <= k1; ++i) {
    scanf("%d", &tmp);
    qu1.push(tmp);
  }
  scanf("%d", &k2);
  for (int i = 1; i <= k2; ++i) {
    scanf("%d", &tmp);
    qu2.push(tmp);
  }
  int fight = 0;
  while (fight <= _max) {
    if (qu1.empty()) {
      printf("%d %d\n", fight, 2);
      break;
    } else if (qu2.empty()) {
      printf("%d %d\n", fight, 1);
      break;
    }
    int tmp1 = qu1.front();
    int tmp2 = qu2.front();
    qu1.pop();
    qu2.pop();
    if (tmp1 > tmp2) {
      qu1.push(tmp2);
      qu1.push(tmp1);
    } else {
      qu2.push(tmp1);
      qu2.push(tmp2);
    }
    fight++;
  }
  if (fight > _max) puts("-1");
  return 0;
}
