#include <iostream>

using namespace std;

//#define broj long long int
#define broj int

int main()
{
    broj n, m, i, j;
    broj a[n], b[n], c[m], d[m];
    broj sC=0, sD = 0;
    cin >> n >> m;
    for(i=0;i<n;i++)
    {
        cin >> a[i] >> b[i];
    }
    for(j=0;j<m;j++)
    {
        cin >> c[j] >> d[j];
        sC += c[j];
        sD += d[j];
    }

    cout << n*m*a[0] << endl;
    cout << n*m << endl;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cout << i+1 << " " << j+1 << " " << a[0] << endl;
        }
    }
}