#include <iostream>
#include <cstring>
using namespace std;
const int MAX_SIZE = 1000;
bool isLetter(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
bool isBigLetter(char c) {
return c >= 'A' && c <= 'Z';
}
bool isSmallLetter(char c) {
return c >= 'a' && c <= 'a';
}
bool checkCaps(char text[]) {
int n = strlen(text);
for (int i = 0; i < n; ++i) {
if (isBigLetter(text[i])) {
text[i] -= ('a' - 'A');
}
}
return strstr(text, "caps") == 0;
}
void processWords(char text[], bool &capsLock) {
int n = strlen(text), lettersCount = 0;
bool isWord = false;
for (int i = 0; i <= n; ++i) {
if (isLetter(text[i])) {
if (isBigLetter(text[i]) && capsLock) {
text[i] += ('a' - 'A');
}
if (isSmallLetter(text[i]) && !capsLock) {
text[i] -= ('a' - 'A');
}
isWord = true;
++lettersCount;
} else if (isWord) {
char temp = text[i];
text[i] = 0;
cout << text + i - lettersCount << ", ";
if (checkCaps(text + i - lettersCount)) {
if (!capsLock) {
capsLock = true;
} else {
capsLock = false;
}
}
text[i] = temp;
isWord = false;
lettersCount = 0;
}
}
}
int main() {
char text[MAX_SIZE + 1] = {0};
bool capsLock = false;
while (cin.getline(text, MAX_SIZE + 1)) {
processWords(text, capsLock);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhfU0laRSA9IDEwMDA7Cgpib29sIGlzTGV0dGVyKGNoYXIgYykgewoJcmV0dXJuIChjID49ICdhJyAmJiBjIDw9ICd6JykgfHwgKGMgPj0gJ0EnICYmIGMgPD0gJ1onKTsKfQoKYm9vbCBpc0JpZ0xldHRlcihjaGFyIGMpIHsKCXJldHVybiBjID49ICdBJyAmJiBjIDw9ICdaJzsKfQoKYm9vbCBpc1NtYWxsTGV0dGVyKGNoYXIgYykgewoJcmV0dXJuIGMgPj0gJ2EnICYmIGMgPD0gJ2EnOwp9Cgp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