#include <bits/stdc++.h>
using namespace std;
int n, q, t, k, d, ans;
map<char, char> mp, mp2;
bool vis[1000];
int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == b[i]) vis[a[i]] = 1;
    if ((mp[a[i]]) && (mp[a[i]] != b[i])) {
      puts("-1");
      return 0;
    }
    if ((mp[b[i]]) && (mp[b[i]] != a[i])) {
      puts("-1");
      return 0;
    }
    if ((mp2[a[i]]) && (mp2[a[i]] != b[i])) {
      puts("-1");
      return 0;
    }
    if ((mp2[b[i]]) && (mp2[b[i]] != a[i])) {
      puts("-1");
      return 0;
    }
    if (a[i] != b[i] && (!mp[a[i]] && !mp[b[i]])) {
      if (vis[a[i]] || vis[b[i]]) {
        puts("-1");
        return 0;
      }
      ans++;
      mp[a[i]] = b[i];
      mp2[b[i]] = a[i];
    }
  }
  map<char, char>::iterator it;
  cout << ans << endl;
  for (int i = 'a'; i <= 'z'; i++) {
    if (mp[i]) printf("%c", i), cout << ' ' << mp[i] << endl;
  }
  return 0;
}
