#include <iostream>
#include <fstream>
using namespace std;
ifstream f("date.in");
int main(){
int ante, x, nr=1;
f >> ante;
while(!f.eof()){
f >> x;
if(x!=ante){
cout << ante << " " << nr << endl;;
nr = 1;
}
else nr++;
ante=x;
}
cout << x << " " << nr;
}