#include <bits/stdc++.h>
using namespace std;
pair<long long, int> mic[202020];
long long c[202020];
const int N = 1 << 20;
pair<long long, int> st[2 * N];
void setm(int i, pair<long long, int> x) {
  for (i += N; i; i /= 2) {
    st[i] = max(st[i], x);
  }
}
pair<long long, int> getmax(int a, int b) {
  a += N;
  b += N;
  pair<long long, int> ma = {0, 0};
  while (a <= b) {
    if (a % 2) ma = max(ma, st[a++]);
    if (!(b % 2)) ma = max(ma, st[b--]);
    a /= 2;
    b /= 2;
  }
  return ma;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<pair<long long, long long>, int> > ss(n);
  set<long long> ccs;
  map<long long, int> ccm;
  for (int i = 0; i < n; i++) {
    cin >> ss[i].first.first >> ss[i].first.second;
    ss[i].second = i + 1;
    ccs.insert(ss[i].first.second);
  }
  vector<pair<pair<pair<long long, long long>, long long>, int> > tv(m);
  for (int i = 0; i < m; i++) {
    cin >> tv[i].first.first.first >> tv[i].first.first.second >>
        tv[i].first.second;
    tv[i].second = i + 1;
    c[i + 1] = tv[i].first.second;
    ccs.insert(tv[i].first.first.second);
  }
  int co = 0;
  for (long long cc : ccs) {
    ccm[cc] = co++;
  }
  sort(ss.begin(), ss.end());
  sort(tv.begin(), tv.end());
  int i2 = 0;
  pair<long long, int> ma = {0, 0};
  for (int i = 0; i < m; i++) {
    while (i2 < n && ss[i2].first.first <= tv[i].first.first.first) {
      ma = max(ma, {ss[i2].first.second, ss[i2].second});
      i2++;
    }
    if (ma.first > tv[i].first.first.first) {
      mic[tv[i].second] = max(
          mic[tv[i].second],
          {min(ma.first, tv[i].first.first.second) - tv[i].first.first.first,
           ma.second});
    }
  }
  pair<long long, pair<int, int> > v = {0, {0, 0}};
  i2 = 0;
  for (int i = 0; i < n; i++) {
    while (i2 < m && tv[i2].first.first.first <= ss[i].first.first) {
      setm(ccm[tv[i2].first.first.second],
           {tv[i2].first.second, tv[i2].second});
      i2++;
    }
    auto asd = getmax(ccm[ss[i].first.second], N - 1);
    if (asd.first > 0) {
      v = max(v, {asd.first * (ss[i].first.second - ss[i].first.first),
                  {ss[i].second, asd.second}});
    }
  }
  for (int i = 0; i < n; i++) {
    swap(ss[i].first.first, ss[i].first.second);
  }
  for (int i = 0; i < m; i++) {
    swap(tv[i].first.first.first, tv[i].first.first.second);
  }
  sort(ss.begin(), ss.end());
  sort(tv.begin(), tv.end());
  i2 = n - 1;
  ma = {1e9 + 10, 0};
  for (int i = m - 1; i >= 0; i--) {
    while (i2 >= 0 && ss[i2].first.first >= tv[i].first.first.first) {
      ma = min(ma, {ss[i2].first.second, ss[i2].second});
      i2--;
    }
    if (ma.first < tv[i].first.first.first) {
      mic[tv[i].second] = max(
          mic[tv[i].second],
          {tv[i].first.first.first - max(ma.first, tv[i].first.first.second),
           ma.second});
    }
  }
  for (int i = 1; i <= m; i++) {
    v = max(v, {mic[i].first * c[i], {mic[i].second, i}});
  }
  cout << v.first << endl;
  if (v.first > 0) {
    cout << v.second.first << " " << v.second.second << endl;
  }
}
