#include <bits/stdc++.h>
using namespace std;
struct event {
  int type;
  int t, id;
  event() {}
  event(int type, int t, int id) : type(type), t(t), id(id) {}
  bool operator<(const event &e) const {
    if (t != e.t) return t < e.t;
    return type < e.type;
  }
};
int n, m;
int l[200010], r[200010], d[200010];
int a[200010], b[200010];
int mx[200010], v[200010];
long long c[200010];
vector<event> e;
pair<int, int> bit[4 * 200010];
void upd(int x, pair<int, int> val) {
  for (; x < 4 * 200010; x += x & -x) bit[x] = max(bit[x], val);
}
pair<int, int> get(int x) {
  pair<int, int> res = make_pair(0, 0);
  for (; x > 0; x -= x & -x) {
    res = max(res, bit[x]);
  }
  return res;
}
void compress() {
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    mp[l[i]] = 1;
    mp[r[i]] = 1;
  }
  for (int i = 0; i < m; i++) {
    mp[a[i]] = 1;
    mp[b[i]] = 1;
  }
  int i = 1;
  for (auto &it : mp) it.second = i++;
  for (int i = 0; i < n; i++) {
    l[i] = mp[l[i]];
    r[i] = mp[r[i]];
  }
  for (int i = 0; i < m; i++) {
    a[i] = mp[a[i]];
    b[i] = mp[b[i]];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    d[i] = r[i] - l[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int z = 0; z < 2; z++) {
    priority_queue<pair<int, int> > pq;
    e.clear();
    for (int i = 0; i < n; i++) {
      e.push_back(event(0, l[i], i));
    }
    for (int i = 0; i < m; i++) {
      e.push_back(event(1, b[i], i));
    }
    sort(e.begin(), e.end());
    for (auto ee : e) {
      int type = ee.type, t = ee.t, id = ee.id;
      if (type == 0) {
        pq.push(make_pair(-l[id], id));
      } else {
        while (!pq.empty()) {
          int ll = -pq.top().first, i = pq.top().second;
          if (r[i] >= b[id]) break;
          pq.pop();
        }
        if (pq.empty()) continue;
        int ll = max(-pq.top().first, a[id]);
        if (mx[id] < b[id] - ll) {
          mx[id] = b[id] - ll;
          v[id] = pq.top().second + 1;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      l[i] *= -1;
      r[i] *= -1;
      swap(l[i], r[i]);
    }
    for (int i = 0; i < m; i++) {
      a[i] *= -1;
      b[i] *= -1;
      swap(a[i], b[i]);
    }
  }
  compress();
  e.clear();
  for (int i = 0; i < n; i++) {
    e.push_back(event(1, l[i], i));
  }
  for (int i = 0; i < m; i++) {
    e.push_back(event(0, a[i], i));
  }
  sort(e.begin(), e.end());
  reverse(e.begin(), e.end());
  for (auto ee : e) {
    int type = ee.type, id = ee.id;
    if (type == 1) {
      upd(r[id], make_pair(d[id], id + 1));
    } else {
      pair<int, int> p = get(b[id]);
      if (mx[id] < p.first) {
        mx[id] = p.first;
        v[id] = p.second;
      }
    }
  }
  long long best = 0, ans = -1;
  for (int i = 0; i < m; i++) {
    if (best < c[i] * mx[i]) {
      best = c[i] * mx[i];
      ans = i;
    }
  }
  cout << best << '\n';
  if (best) {
    cout << v[ans] << ' ' << ans + 1 << '\n';
  }
}
