#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<pair<int, int> > ns;
vector<pair<pair<int, int>, int> > ns_;
vector<int> nid;
const int p2 = 1 << 18;
int seg[p2 * 2];
int getmax(int a, int b, int l, int r, int k) {
  if (b <= l || r <= a) return 0;
  if (a <= l && r <= b) return seg[k];
  return max(getmax(a, b, l, (l + r) / 2, k * 2),
             getmax(a, b, (l + r) / 2, r, k * 2 + 1));
}
int a_[200000], b_[200000], c_[200000];
int main() {
  cin >> N >> M;
  for (int i = 0; i < (int)(N); i++) {
    int l, r;
    cin >> l >> r;
    if (l == r) continue;
    ns_.push_back(pair<pair<int, int>, int>(pair<int, int>(l, -r), i + 1));
  }
  sort(ns_.begin(), ns_.end());
  int r = 0;
  for (pair<pair<int, int>, int> pp : ns_) {
    pair<int, int> p = pp.first;
    if (-p.second > r) {
      ns.push_back(pair<int, int>(p.first, -p.second));
      nid.push_back(pp.second);
      r = max(r, -p.second);
    }
  }
  int N = ns.size();
  for (int i = 0; i < (int)(N); i++) {
    seg[p2 + i] = ns[i].second - ns[i].first;
  }
  for (int i = p2 - 1; i > 0; i--) seg[i] = max(seg[i * 2], seg[i * 2 + 1]);
  long long ans = 0, id = 0;
  for (int tt = 0; tt < (int)(M); tt++) {
    int a, b;
    int c;
    scanf("%d%d%d", a_ + tt, b_ + tt, c_ + tt);
    a = a_[tt], b = b_[tt], c = c_[tt];
    int ub = N, lb = -1;
    while (ub - lb > 1) {
      int m = (ub + lb) / 2;
      if (a < ns[m].first)
        ub = m;
      else
        lb = m;
    }
    int l = ub;
    ub = N, lb = -1;
    while (ub - lb > 1) {
      int m = (ub + lb) / 2;
      if (b > ns[m].second)
        lb = m;
      else
        ub = m;
    }
    int r = lb;
    int tmp = 0;
    if (l <= r) tmp = getmax(l, r + 1, 0, p2, 1);
    if (l >= 1)
      tmp = max(tmp, min(b, ns[l - 1].second) - max(ns[l - 1].first, a));
    if (r <= N - 2)
      tmp = max(tmp, min(b, ns[r + 1].second) - max(ns[r + 1].first, a));
    if (ans < (long long)tmp * c) {
      ans = (long long)tmp * c;
      id = tt;
    }
  }
  cout << ans << endl;
  if (ans == 0) {
    return 0;
  }
  int a = a_[id], b = b_[id], c = c_[id];
  for (int i = 0; i < (int)(N); i++) {
    if ((min(b, ns[i].second) - max(a, ns[i].first)) * (long long)c == ans) {
      cout << nid[i] << " " << id + 1 << endl;
      return 0;
    }
  }
}
