Technocup 2017 - Elimination Round 3
B
Santa Claus and Keyboard Check
Codeforces
1500
原题
← AC →
翻译中…

Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be.

翻译中…

In order to make sure that he's right and restore the correct order of keys, Santa typed his favorite patter looking only to his keyboard.

翻译中…

You are given the Santa's favorite patter and the string he actually typed. Determine which pairs of keys could be mixed. Each key must occur in pairs at most once.

翻译中…

Input

翻译中…

The input consists of only two strings $*s*$ and $*t*$ denoting the favorite Santa's patter and the resulting string. $*s*$ and $*t*$ are not empty and have the same length, which is at most $1000$. Both strings consist only of lowercase English letters.

翻译中…

Output

翻译中…

If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print «-1» (without quotes).

翻译中…

Otherwise, the first line of output should contain the only integer $*k*$ ($*k* ≥ 0$) — the number of pairs of keys that should be swapped. The following $*k*$ lines should contain two space-separated letters each, denoting the keys which should be swapped. All printed letters must be distinct.

翻译中…

If there are several possible answers, print any of them. You are free to choose the order of the pairs and the order of keys in a pair.

翻译中…

Each letter must occur at most once. Santa considers the keyboard to be fixed if he can print his favorite patter without mistakes.

翻译中…

样例

Input #1
helloworld
ehoolwlroz
Output #1
3
h e
l o
d z
InputCopy OutputCopy
Input #2
hastalavistababy
hastalavistababy
Output #2
0
InputCopy OutputCopy
Input #3
merrychristmas
christmasmerry
Output #3
-1
InputCopy OutputCopy
题目信息
题号
748B
时间限制
2 s
内存限制
256 MB
标签
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。