#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  while (getline(cin, a) && getline(cin, b)) {
    set<int> aa, bb;
    int hit = 0;
    int blow = 0;
    for (int i = 0; i != a.size() + 1; i += 2) {
      if (a[i] == b[i]) {
        ++hit;
      } else {
        aa.insert(a[i] - '0');
        bb.insert(b[i] - '0');
      }
    }
    for (int i = 1; i <= 9; ++i) {
      if (aa.count(i) && bb.count(i)) {
        cout << i << endl;
        ++blow;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}
