#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    freopen("wall.in", "r", stdin);
    freopen("wall.out", "w", stdout);
    int n, m;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cin >> m;
    vector<int> b(m);
    for (int j = 0; j < m; j++)
        cin >> b[j]; 
    cout << 1 << " " << min(n, m);
    for (int i = 0; i < min(n, m); i++)
        cout << i << " " << i << endl;
    return 0;
}