#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
ifstream file("anagram.txt");
for(int row = 0; row < 200; row++) {
string words[5], sorted_words[5];
for(int word_num = 0; word_num < 5; word_num++) {
file >> words[word_num];
sorted_words[word_num] = words[word_num];
sort(sorted_words[word_num].begin(), sorted_words[word_num].end());
}
bool anagrams = true;
for(int word_num = 1; word_num < 5; word_num++) {
if(sorted_words[word_num] != sorted_words[0]) {
anagrams = false;
break;
}
}
if(anagrams) {
for(auto word : words) {
cout << word << " ";
}
cout << endl;
}
}
file.close();
return 0;
}