#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 1 << 20;
vector<int> xs;
inline int getid(int x) {
  return lower_bound((xs).begin(), (xs).end(), x) - xs.begin();
}
inline int get_len(int l, int r) { return xs[r] - xs[l]; }
pair<int, int> a[N], b[N];
int coef[N];
vector<int> start_a[N], start_b[N];
vector<int> end_a[N], end_b[N];
namespace max_tree {
pair<int, int> t[N << 1];
void init() {
  for (int i = 0; i < N + N; i++) t[i] = {-inf, -1};
}
void upd(int x, int v, int id) {
  x += N;
  if (t[x] < pair<int, int>(v, id)) {
    t[x] = {v, id};
    while (x > 1) {
      x >>= 1;
      t[x] = max(t[x + x], t[x + x + 1]);
    }
  }
}
pair<int, int> get(int l, int r) {
  pair<int, int> res = {-inf, -1};
  for (l += N, r += N; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) umax(res, t[l++]);
    if (~r & 1) umax(res, t[r--]);
  }
  return res;
}
}  // namespace max_tree
long long ans = 0ll;
int X, Y;
void upd(int x, int y, long long tmp) {
  if (tmp > ans) {
    ans = tmp;
    X = x;
    Y = y;
  }
}
int main() {
  int n = read();
  int m = read();
  for (int i = 0; i < n; i++) {
    a[i].first = read();
    a[i].second = read();
    xs.push_back(a[i].first);
    xs.push_back(a[i].second);
  }
  for (int i = 0; i < m; i++) {
    b[i].first = read();
    b[i].second = read();
    xs.push_back(b[i].first);
    xs.push_back(b[i].second);
    coef[i] = read();
  }
  {
    sort((xs).begin(), (xs).end());
    xs.erase(unique((xs).begin(), (xs).end()), xs.end());
    for (int i = 0; i < n; i++) {
      a[i].first = getid(a[i].first);
      a[i].second = getid(a[i].second);
      start_a[a[i].first].push_back(i);
      end_a[a[i].second].push_back(i);
    }
    for (int i = 0; i < m; i++) {
      b[i].first = getid(b[i].first);
      b[i].second = getid(b[i].second);
      start_b[b[i].first].push_back(i);
      end_b[b[i].second].push_back(i);
    }
  }
  {
    max_tree::init();
    for (int i = 0; i < N; i++) {
      for (int id : end_a[i]) {
        max_tree::upd(a[id].first, get_len(a[id].first, a[id].second), id);
      }
      for (int id : end_b[i]) {
        auto tmp = max_tree::get(b[id].first, N - 1);
        if (tmp.second != -1)
          upd(tmp.second, id, (long long)tmp.first * coef[id]);
      }
    }
  }
  {
    pair<int, int> best(-1, -1);
    for (int i = 0; i < N; i++) {
      for (int id : start_a[i]) {
        umax(best, pair<int, int>(a[id].second, id));
      }
      for (int id : start_b[i]) {
        if (best.first == -1) continue;
        if (best.first >= b[id].second) {
          upd(best.second, id,
              (long long)get_len(b[id].first, b[id].second) * coef[id]);
        } else if (best.first >= b[id].first) {
          upd(best.second, id,
              (long long)get_len(b[id].first, best.first) * coef[id]);
        }
      }
    }
  }
  {
    pair<int, int> best(inf, -1);
    for (int i = N - 1; i >= 0; i--) {
      for (int id : end_a[i]) {
        umin(best, pair<int, int>(a[id].first, id));
      }
      for (int id : end_b[i]) {
        if (best.first == inf) continue;
        if (best.first <= b[id].second && best.first >= b[id].first)
          upd(best.second, id,
              (long long)get_len(best.first, b[id].second) * coef[id]);
      }
    }
  }
  cout << ans << endl;
  if (ans > 0) {
    printf("%d %d\n", X + 1, Y + 1);
  }
  return 0;
}
