// ~~ icebear love attttttt ~~
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "roadsigns"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 4e5 + 5;
int n, x[N], a[N], b[N];
int A[N], B[N];
void init(void) {
cin >> n;
FOR(i, 1, n) {
cin >> x[i] >> a[i] >> b[i];
A[i] = x[i] - a[i];
B[i] = x[i] + b[i];
}
}
namespace Subtask1 {
bool check() {
FOR(i, 1, n) if (a[i] != a[1] || b[i] != b[1])
return false;
return true;
}
void solve() {
cout << 2 << ' ' << 2 * (n - 1);
}
}
namespace Subtask2 {
int range[N]; // first j > i that A[j] != A[i]
bool check() {
FOR(i, 1, n) if (a[i] != a[1])
return false;
return true;
}
void solve() {
FORR(i, n, 1) range[i] = (A[i] != A[i + 1] ? i + 1 : range[i + 1]);
int maxLen = 0, numLen = 0;
FOR(u, 1, n - 1) {
// L = A[u]
int j = range[u];
int v = j + 1;
if (A[v] == A[u]) v = range[v];
if (maximize(maxLen, v - u)) numLen = 1;
else if (maxLen == v - u) numLen++;
// R = B[u]
v = range[u + 1];
if (maximize(maxLen, v - u)) numLen = 1;
else if (maxLen == v - u) numLen++;
}
cout << maxLen << ' ' << numLen;
}
}
namespace Subtask34 {
bool check() {
return n <= 10000;
}
int rangeA[N], rangeB[N];
void solve() {
FORR(i, n, 1) rangeA[i] = (A[i] != A[i + 1] ? i + 1 : rangeA[i + 1]);
FORR(i, n, 1) rangeB[i] = (B[i] != B[i + 1] ? i + 1 : rangeB[i + 1]);
if (max(rangeA[1], rangeB[1]) == n + 1) {
cout << n << ' ' << -1;
return;
}
int maxLen = 0, numLen = 0;
FOR(u, 1, n) {
// L = A[u]
int j = rangeA[u];
int v = j;
while(v <= n && (A[v] == A[u] || B[v] == B[j])) v++;
if (maximize(maxLen, v - u)) numLen = 1;
else if (maxLen == v - u) numLen++;
// R = B[u]
j = rangeB[u];
v = j;
while(v <= n && (B[v] == B[u] || A[v] == A[j])) v++;
if (maximize(maxLen, v - u)) numLen = 1;
else if (maxLen == v - u) numLen++;
}
cout << maxLen << ' ' << numLen;
}
}
void process(void) {
if (Subtask1 :: check()) Subtask1 :: solve();
else if (Subtask2 :: check()) Subtask2 :: solve();
else if (Subtask34 :: check()) Subtask34 :: solve();
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4gaWNlYmVhciBsb3ZlIGF0dHR0dHR0IH5+CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGludCBsb25nIGxvbmcKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgcGFpcjxpbnQsIGludD4gaWk7CnR5cGVkZWYgcGFpcjxpbnQsIGlpPiBpaWk7Cgp0ZW1wbGF0ZTxjbGFzcyBUPgogICAgYm9vbCBtaW5pbWl6ZShUICZhLCBjb25zdCBUICZiKSB7CiAgICAgICAgaWYgKGEgPiBiKSByZXR1cm4gYSA9IGIsIHRydWU7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQoKdGVtcGxhdGU8Y2xhc3MgVD4KICAgIGJvb2wgbWF4aW1pem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aV0gIT0gYlsxXSkKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIHJldHVybiB0cnVlOwogICAgfQoKICAgIHZvaWQgc29sdmUoKSB7CiAgICAgICAgY291dCA8PCAyIDw8ICcgJyA8PCAyICogKG4gLSAxKTsKICAgIH0KfQoKbmFtZXNwYWNlIFN1YnRhc2syIHsKICAgIGludCByYW5nZVtOXTsgLy8gZmlyc3QgaiA+IGkgdGhhdCBBW2pdICE9IEFbaV0KICAgIGJvb2wgY2hlY2soKSB7CiAgICAgICAgRk9SKGksIDEsIG4pIGlmIChhW2ldICE9IGFbMV0pCiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICB2b2lkIHNvbHZlKCkgewogICAgICAgIEZPUlIoaSwgbiwgMSkgcmFuZ2VbaV0gPSAoQVtpXSAhPSBBW2kgKyAxXSA/IGkgKyAxIDogcmFuZ2VbaSArIDFdKTsKICAgICAgICBpbnQgbWF4TGVuID0gMCwgbnVtTGVuID0gMDsKICAgICAgICBGT1IodSwgMSwgbiAtIDEpIHsKICAgICAgICAgICAgLy8gTCA9IEFbdV0KICAgICAgICAgICAgaW50IGogPSByYW5nZVt1XTsKICAgICAgICAgICAgaW50IHYgPSBqICsgMTsKICAgICAgICAgICAgaWYgKEFbdl0gPT0gQVt1XSkgdiA9IHJhbmdlW3ZdOwogICAgICAgICAgICBpZiAobWF4aW1pemUobWF4TGVuLCB2IC0gdSkpIG51bUxlbiA9IDE7CiAgICAgICAgICAgIGVsc2UgaWYgKG1heExlbiA9PSB2IC0gdSkgbnVtTGVuKys7CgogICAgICAgICAgICAvLyBSID0gQlt1XQogICAgICAgICAgICB2ID0gcmFuZ2VbdSArIDFdOwogICAgICAgICAgICBpZiAobWF4aW1pemUobWF4TGVuLCB2IC0gdSkpIG51bUxlbiA9IDE7CiAgICAgICAgICAgIGVsc2UgaWYgKG1heExlbiA9PSB2IC0gdSkgbnVtTGVuKys7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgbWF4TGVuIDw8ICcgJyA8PCBudW1MZW47CiAgICB9Cn0KCm5hbWVzcGFjZSBTdWJ0YXNrMzQgewogICAgYm9vbCBjaGVjaygpIHsKICAgICAgICByZXR1cm4gbiA8PSAxMDAwMDsKICAgIH0KCiAgICBpbnQgcmFuZ2VBW05dLCByYW5nZUJbTl07CiAgICB2b2lkIHNvbHZlKCkgewogICAgICAgIEZPUlIoaSwgbiwgMSkgcmFuZ2VBW2ldID0gKEFbaV0gIT0gQVtpICsgMV0gPyBpICsgMSA6IHJhbmdlQVtpICsgMV0pOwogICAgICAgIEZPUlIoaSwgbiwgMSkgcmFuZ2VCW2ldID0gKEJbaV0gIT0gQltpICsgMV0gPyBpICsgMSA6IHJhbmdlQltpICsgMV0pOwogICAgICAgIGlmIChtYXgocmFuZ2VBWzFdLCByYW5nZUJbMV0pID09IG4gKyAxKSB7CiAgICAgICAgICAgIGNvdXQgPDwgbiA8PCAnICcgPDwgLTE7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaW50IG1heExlbiA9IDAsIG51bUxlbiA9IDA7CiAgICAgICAgRk9SKHUsIDEsIG4pIHsKICAgICAgICAgICAgLy8gTCA9IEFbdV0KICAgICAgICAgICAgaW50IGogPSByYW5nZUFbdV07CiAgICAgICAgICAgIGludCB2ID0gajsKICAgICAgICAgICAgd2hpbGUodiA8PSBuICYmIChBW3ZdID09IEFbdV0gfHwgQlt2XSA9PSBCW2pdKSkgdisrOwogICAgICAgICAgICBpZiAobWF4aW1pemUobWF4TGVuLCB2IC0gdSkpIG51bUxlbiA9IDE7CiAgICAgICAgICAgIGVsc2UgaWYgKG1heExlbiA9PSB2IC0gdSkgbnVtTGVuKys7CgogICAgICAgICAgICAvLyBSID0gQlt1XQogICAgICAgICAgICBqID0gcmFuZ2VCW3VdOwogICAgICAgICAgICB2ID0gajsKICAgICAgICAgICAgd2hpbGUodiA8PSBuICYmICh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