#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MX = 1 << 18;
const int MOD = 30013;
struct SegmentTree
{
array<pair<int, int>, 2 * MX> t {}; // lis, freq
void calc(int u, auto& t)
{
if (t[u * 2].first == t[u * 2 + 1].first)
t[u].first = t[u * 2].first, t[u].second = (t[u * 2].second + t[u * 2 + 1].second) % MOD;
else if (t[u * 2].first > t[u * 2 + 1].first)
t[u] = t[u * 2];
else
t[u] = t[u * 2 + 1];
}
void update(int at, pair<int, int> score, int l = 1, int r = MX - 1, int u = 1)
{
if (r - l > 1)
{
int m = (l + r) / 2;
if (at < m)
update(at, score, l, m, u * 2);
else
update(at, score, m, r, u * 2 + 1);
calc(u, t);
}
else t[u] = score;
}
pair<int, int> query(int r) { return query(0, MX - 1, 0, r, 1); }
pair<int, int> query(int l, int r, int L, int R, int u)
{
if (R <= l || r <= L)
return {0, 0};
if (L <= l && r <= R)
return t[u];
if (r - l > 1)
{
int m = (l + r) / 2;
array<pair<int, int>, 4> temp;
temp[2] = query(l, m, L, R, u * 2);
temp[3] = query(m, r, L, R, u * 2 + 1);
calc(1, temp);
return temp[1];
}
return t[u];
}
};
int main()
{
cin.tie(NULL) -> sync_with_stdio(false);
int N;
cin >> N;
vector<array<int, 4>> sweep(N);
map<int, int> comp;
for (auto& [a, b, c, d] : sweep)
cin >> a >> b >> c >> d, comp[c], comp[d];
for (int cnt = 0; auto& i : comp)
i.second = cnt++;
auto byb = sweep;
sort(sweep.begin(), sweep.end());
sort(byb.begin(), byb.end(), [](auto& x, auto& y) { return x[1] < y[1]; });
SegmentTree seg;
int best = 0;
int freq = 0;
vector<pair<int, int>> score(2 * N);
int i = 0;
for (auto& [a, b, c, d] : sweep)
{
for (; i < N && byb[i][1] < a; ++i)
seg.update(comp[byb[i][3]], score[comp[byb[i][3]]]);
auto [curBest, curFreq] = seg.query(comp[c]);
if (curBest == 0)
++curFreq;
++curBest;
if (curBest == best)
freq = (freq + curFreq) % MOD;
else if (curBest > best)
best = curBest, freq = curFreq;
score[comp[d]] = {curBest, curFreq};
}
cout << best << ' ' << freq << endl;
return 0;
} /*****************************=
-+**********************************=
:-*****************************************+:
..:*************+=+*******************************=.
..-==*****************+=-+*****************************+.
..-=***********************+--+****************************=
:+**************#*#**********+--+***************************- .=--=.
.+*********************#*********+--****************************++++----:
-+***********************##*********--+********************************+--=.
=****=**********************#*********+-=***************************#*****+--=
.=****+***********************************-=*********************#*****##*****=-=.
:=*****=************************************=-*****************#******#####*****=-=.
.=**+***=**************************#**********==***********##*******#**######*****+-=.
+***=***+***************************#**********-+*****####********#*****#####******+-=:
=+**=****+****************#**********************-*####*********##***#*#######*******+-=.
.=*#*=****=****************#***********#**********++#*********###****#*#*######********+-=.
=**#++****=***#******#******#***********#**********=*******####****##**#########********=-=
.=*##=****#=***#*******#*****#*#*********#*#********+****#####****###**#*######%#*********-==
-*###=**###+*#*#######*##*######*######**##########*#*####*....-#########%##%##%##########=-*.
=*###+######+############################################=..+=-+.########%##%##%##########*-+*
+###*+######**#################%##########%###########%#*..=-+===-######%###+##%###########-+#.
.+###**#######+###%############%#%#########%###########%#...=*:.=:.#####%#%%#+##%###########=+#+
.-+#%#**#######%=###%#############%%######%#%%##########*...+===+...####%%%%% *%%############=+##
.=*#%#*+#######%%+##%%###########%#%%%######%%#%########=...====+..####%%%%%: *%%############=*##
.+*#*##+###%###%%%%##%%##########*##%%%####%%%#%#######%*=-..====:####%%%%%= #%%############=###-
.+*#=#-=#####%#%%%####%%%########+*###%%%##%%%#%#######%*==:==+-.*##%%%%%%+ #%%###########*=###+
:=##=#-+####%%#%%%#**##%%%#######+++#*+%*%%%%%#%%########=.-=....##%%%%%%*....%%%#####%#####+=####-
.#*.#--*#####%#%%#****##%%#####+-===#+=**+%%%#%%########=......+%%%%%%%+ %%######%#####=*####.
#* *+.*####%%%%%#++++- :*%%###+.....--..*==#%%%########==-:::=%%%%%%%- %%######%#####=#####.
-# .%.=####%%%%%#++=*......:##*.......-..-==%%%#####%##=#%%%%%%%%%%# #%######%####*=###%#
*. +-.####%%%%%%===.=....-:.*#...........-=%%%#######*==*@%%%%%%%* #%######%####+*###%#
*.:###%%%%%%-.....=......*:...........-%%%######%+*==*#%%%%%# +%######%####=####%#.
=.=###%%%%%:.............:............#*%%####*#*=====%@%%% :%#####%%####+######:
.=%##%%%%%*.............:............#*%%####+#+======%#%* .:-=%%%%%%%%###+#####+#-
.%%##%%%-*-..............::::.......#+%%####+#=====-...#: :*%%%%%%%%%%%%%%%%###*#####=#=
.####%%%:.:-.......--...............#=#%###+*#====-...:*%%%%%%%%%%%%%%%%%%%%%%########:#+
*-#%#%%- -..........:----........:*=#%##%=*+=====#%%%%%%%%%%%%%%%%%%%%%%%%%%########:#*
=*.%%%%= .:........:::..........=.=####+=#=*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###.*#
#..%%%#. -....................-:+###%*%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*#
+- :%%%#+ =..................===%##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#:.
.#. =%% .*= -.............:+#%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+.
.* *%- .-........:*%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%%%%#.
.=. ## ..-:..:#%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%:
..=*- .*@@@@@%%%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-.
#@%%%%%%%%%%%%%%%%%%%@%%%@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*:.
*@%%%%%%%%%%%%%%%%%%%%%@@@%@@@@%%%%%@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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