#include<iostream>
#include<fstream>
using namespace std;
struct Pair{
int a, b, s;
};
struct Pair p[1024];
int w, px, pos, pre, pres, totalLen;
inline int abs(int a){
return a >= 0 ? a : -a;
}
inline int max(int a, int b){
return a >= b ? a : b;
}
inline int min(int a, int b){
return a <= b ? a : b;
}
void printO(void){
cout << pre << ' ' << pres << endl;
}
int getUp(int pos){
int tpos = pos - w;
if (tpos < 0)
tpos = pos;
return tpos;
}
int getDown(int pos){
int tpos = pos + w;
if (tpos >= totalLen)
tpos = pos;
return tpos;
}
int getLeft(int pos){
int tpos = pos - 1;
if (tpos / w != pos / w)
tpos = pos;
return tpos;
}
int getRight(int pos){
int tpos = pos + 1;
if (tpos / w != pos / w || tpos >= totalLen)
tpos = pos;
return tpos;
}
int getLeftUp(int pos){
int tpos = pos - w - 1;
if (tpos < 0 || tpos / w + 1 != pos / w)
tpos = pos;
return tpos;
}
int getRightUp(int pos){
int tpos = pos - w + 1;
if (tpos < 0 || tpos / w == pos / w)
tpos = pos;
return tpos;
}
int getLeftDown(int pos){
int tpos = pos + w - 1;
if (tpos / w == pos / w || tpos >= totalLen)
tpos = pos;
return tpos;
}
int getRightDown(int pos){
int tpos = pos + w + 1;
if (tpos / w != pos / w + 1 || tpos >= totalLen)
tpos = pos;
return tpos;
}
int getValue(int pos){
pos++;
int lo = 1, hi = px - 1, mid = px / 2;
while (lo < hi){
mid = (lo + hi) >> 1;
if (pos <= p[mid].s)
hi = mid;
else
lo = mid + 1;
}
return p[hi].a;
}
int getLenPos(int pos){
pos++;
int lo = 1, hi = px - 1, mid = px / 2;
while (lo < hi){
mid = (lo + hi)>>1;
if (pos <= p[mid].s)
hi = mid;
else
lo = mid + 1;
}
return p[hi].s;
}
int getLen(int pos){
return getLenPos(pos) - pos ;
}
int getMax(int pos){
int value = getValue(pos);
int a = 0;
int tpos;
tpos = getUp(pos);
if (pos != tpos)
a = abs(value - getValue(tpos));
tpos = getDown(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getLeft(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getRight(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getLeftUp(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getLeftDown(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getRightUp(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
tpos = getRightDown(pos);
if (pos != tpos)
a = max(a, abs(value - getValue(tpos)));
return a;
}
int getMidMax(int pos){
int value = getValue(pos);
int a = abs(value - getValue(getUp(pos)));
return max(a, abs(value - getValue(getDown(pos))));
}
int main(){
ifstream cin("input.txt");
while (cin>>w && w){
cout << w << endl;
int a, b, c;
p[0].s = 0;
px = 1;
while (cin>>a>>b && !(a==0 && b==0)){
p[px].a = a;
p[px].b = b;
p[px].s = p[px - 1].s + b;
px++;
}
totalLen = p[px - 1].s;
int value = p[1].a;
pres = 1;
pre = abs(value - getValue(getDown(0)));
pre = max(pre, abs(value - getValue(getRight(0))));
pre = max(pre, abs(value - getValue(getRightDown(0))));
pos = 1;
int pos_len, up_len, down_len, min_len,pos_up,pos_down,pos_left;
while (pos<totalLen){
pos_len = getLen(pos);
pos_up = getUp(pos);
pos_down = getDown(pos);
pos_left = getLeft(pos);
up_len = getLen(pos_up);
if (pos_down != pos)
down_len = getLen(getDown(pos));
else
down_len = pos_len;
if (pos_up==pos)
up_len = up_len <= (w-pos)?up_len:(w-pos);
min_len = min(pos_len, min(up_len, down_len));
if (min_len == 1){
a = getMax(pos);
if (a == pre){
pres++;
}
else{
printO();
pre = a;
pres = 1;
}
pos++;
}
else if (min_len == 2){
a = getMax(pos);
b = getMax(getRight(pos));
if (a == pre){
pres++;
}
else{
printO();
pre = a;
pres = 1;
}
if (b == pre){
pres++;
}
else{
printO();
pre = b;
pres = 1;
}
pos += 2;
}
else{
a = getMax(pos);
b = getMax(pos + min_len - 1);
c = getMidMax(pos + 1);
if (a == pre){
pres++;
}
else{
printO();
pre = a;
pres = 1;
}
if (c == pre){
pres += min_len - 2;
}
else{
printO();
pre = c;
pres = min_len - 2;
}
if (b == pre){
pres++;
}
else{
printO();
pre = b;
pres = 1;
}
pos += min_len;
}
}
printO();
cout << "0 0" << endl;
}
cout << 0 << endl;
}