let baseChars = "abcdefghijklm".map({$0}) let inpt = readLine()!.map({$0}) let imp = "Impossible" var isImp = false; var dic = [Character:Int]() for c in inpt { if(!baseChars.contains(c)) { isImp = true break } dic[c] = inpt.filter({$0 == c}).count if(dic[c]! > 2) { isImp = true break } } if(!isImp) { if(dic.count == baseChars.count) { for c in baseChars { print(c) } } else { let tmp = baseChars.filter({!inpt.contains($0)})[0] print(tmp) } } else { print(imp) }