/**
* @brief : GNU C++11 application
* @details : Works stably on GNU C++11 (g++ 4.9.2, flag -std=c++11)
*
* @author : SergeiEgorov
* @date : July 10, 2015
*/
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define file "file"
constexpr char el = '\n';
constexpr int inf = (int) 1e9 + 7;
constexpr long long l_inf = (long long) 4e18 + 13ll;
constexpr long double eps = 1e-9;
constexpr long long mod = (1ll << 62);
string s;
inline string solve()
{
for (int i = s.size() - 1; i >= 0; )
{
if (i >= 5 && s.substr(i - 5, 6) == "output")
{
i -= 6;
continue;
}
if (i >= 4 && (s.substr(i - 4, 5) == "input" || s.substr(i - 4, 5) == "puton"))
{
i -= 5;
continue;
}
if (i >= 2 && (s.substr(i - 2, 3) == "one" || s.substr(i - 2, 3) == "out"))
{
i -= 3;
continue;
}
if (i >= 1 && s.substr(i - 1, 2) == "in")
{
i -= 2;
continue;
}
return string("NO");
}
return string("YES");
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
srand(time(nullptr));
#ifdef HOME
freopen(file".in", "r", stdin);
freopen(file".out", "w", stdout);
#endif
int T;
cin >> T;
while (T--)
{
cin >> s;
cout << solve() << el;
}
return 0;
}
LyoqCiAqIEBicmllZiAgICA6IEdOVSBDKysxMSBhcHBsaWNhdGlvbgogKiBAZGV0YWlscyAgOiBXb3JrcyBzdGFibHkgb24gR05VIEMrKzExIChnKysgNC45LjIsIGZsYWcgLXN0ZD1jKysxMSkKICogCiAqIEBhdXRob3IgICA6IFNlcmdlaUVnb3JvdgogKiBAZGF0ZSAgICAgOiBKdWx5IDEwLCAyMDE1CiAqLwoKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBuYW1lc3BhY2UgX19nbnVfY3h4OwoKI2RlZmluZSBmaWxlICJmaWxlIgoKY29uc3RleHByIGNoYXIgZWwgPSAnXG4nOwpjb25zdGV4cHIgaW50IGluZiA9IChpbnQpID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