#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
int main() {
string str;
map<string, int> mymap;
while (getline(cin, str)) {
//printf("%s\n", str.substr(1, 0).c_str());
int size = str.size();
for (int i = 0; i < size; i++) {
for (int j = i; j < size; j++) {
string sub = str.substr(i, j - i + 1);
if (mymap.find(sub) != mymap.end()) { //有这个元素
mymap[sub]++;
} else { //没这个元素
mymap[sub] = 1;
}
}
}
//sort(mymap.begin(), mymap.end());
for (auto it = mymap.begin(); it != mymap.end(); it++) {
if (it->second > 1) {
printf("%s %d\n", it->first.c_str(), it->second);
}
}
}
}