#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

string s;
int num, cnt;
map<int, bool> ok[2];
map<int, int> res;

int main()
{
  while(getline(cin, s) && s != ""){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[0][num] = true;
    res[num] += 1;
  }

  while(getline(cin, s)){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[1][num] = true;
    if(ok[0][num]) res[num] += 1;
  }

  vrep(v, res) if(ok[1][v->first]) cout << v->first << " " << v->second << endl;

  return 0;
}
### Prompt

Please provide a Cpp coded solution to the problem described below:

There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which you have transactions and the number of transactions for two consecutive months from last month. However, the number of monthly business partners is 1,000 or less.



Input

This month's data and last month's data are given separated by one blank line. Each data is given in the following format.


c1, d1
c2, d2
...
...


ci (1 ≤ ci ≤ 1,000) is an integer representing the customer number, and di (1 ≤ di ≤ 31) is an integer representing the trading day.

Output

For companies that have transactions for two consecutive months, the customer number and the total number of transactions are output separated by a blank in ascending order of customer number.

Example

Input

123,10
56,12
34,14

123,3
56,4
123,5


Output

56 2
123 3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

string s;
int num, cnt;
map<int, bool> ok[2];
map<int, int> res;

int main()
{
  while(getline(cin, s) && s != ""){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[0][num] = true;
    res[num] += 1;
  }

  while(getline(cin, s)){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[1][num] = true;
    if(ok[0][num]) res[num] += 1;
  }

  vrep(v, res) if(ok[1][v->first]) cout << v->first << " " << v->second << endl;

  return 0;
}
```