#include <bits/stdc++.h>
using namespace std;
long long MAXN = 1000000000;
long long n, m, i, j;
vector<pair<pair<long long, long long>, pair<long long, long long> > > v;
vector<pair<pair<long long, long long>, pair<long long, long long> > > v2;
long long l, r;
long long c;
long long answ;
long long h1, h2;
set<pair<long long, pair<long long, long long> > > s;
set<pair<long long, pair<long long, long long> > >::iterator it;
set<pair<long long, pair<long long, long long> > >::iterator it2;
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &l, &r);
    v.push_back(make_pair(make_pair(l, r), make_pair(0, i)));
    v2.push_back(make_pair(make_pair(r, l), make_pair(0, i)));
  }
  for (i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &l, &r, &c);
    v.push_back(make_pair(make_pair(l, r), make_pair(c, i)));
    v2.push_back(make_pair(make_pair(r, l), make_pair(c, i)));
  }
  sort(v.begin(), v.end());
  sort(v2.begin(), v2.end());
  long long ham = -1, h = -1;
  for (i = 0; i < v.size(); i++) {
    l = v[i].first.first;
    r = v[i].first.second;
    c = v[i].second.first;
    if (c == 0) {
      if (ham < r) {
        ham = r;
        h = v[i].second.second;
      }
    } else {
      if (answ < (min(ham, r) - l) * c) {
        answ = (min(ham, r) - l) * c;
        h1 = h;
        h2 = v[i].second.second;
      }
    }
  }
  ham = MAXN + 1;
  h = MAXN + 1;
  for (i = v2.size() - 1; i >= 0; i--) {
    r = v2[i].first.first;
    l = v2[i].first.second;
    c = v2[i].second.first;
    if (c == 0) {
      if (ham > l) {
        ham = l;
        h = v2[i].second.second;
      }
    } else {
      if (answ < (r - max(ham, l)) * c) {
        answ = (r - max(ham, l)) * c;
        h1 = h;
        h2 = v2[i].second.second;
      }
    }
  }
  for (i = 0; i < v.size(); i++) {
    l = v[i].first.first;
    r = v[i].first.second;
    c = v[i].second.first;
    int H = v[i].second.second;
    if (c == 0) {
      s.insert(make_pair(r, make_pair(-1, -1)));
      it = s.find(make_pair(r, make_pair(-1, -1)));
      ++it;
      if (it != s.end()) {
        long long c1 = (*it).second.first;
        if (answ < (r - l) * c1) {
          answ = (r - l) * c1;
          h1 = H;
          h2 = (*it).second.second;
        }
      }
      s.erase(make_pair(r, make_pair(-1, -1)));
    } else {
      s.insert(make_pair(r, make_pair(c, H)));
      it = s.find(make_pair(r, make_pair(c, H)));
      it2 = it;
      ++it2;
      if (it2 != s.end() && (*it2).second.first >= c) {
        s.erase(it);
        continue;
      }
      while (true) {
        it = s.find(make_pair(r, make_pair(c, H)));
        if (it == s.begin()) break;
        --it;
        if ((*it).second.first <= c)
          s.erase(it);
        else
          break;
      }
    }
  }
  printf("%I64d\n", answ);
  if (answ != 0) printf("%I64d %I64d\n", h1, h2);
  return 0;
}
