#include <cstdio>
#include <map>

using namespace std;

int c,d;

int main()
{
    int mp[1000] = {0};
    while( scanf( "%d,%d\n", &c, &d ) != EOF )
    {
        mp[c]++;
    }
    for( int i = 0; i < 1000; i++ )
    {
        if( mp[i] >= 2 )
        {
            printf( "%d %d\n", i, mp[i] );
        }
    }
    return 0;
}
