#include <iostream>
#include <cmath>
using namespace std;

int main(){
	int n , x;
	cin>>n;
	for(int i=1 ; i<=n ; i++){
		x=i;
		if(i%3==0 && x%10!=3){
			cout << " " << i;
		} else if(x%10==3) { 
			cout << " " << i;
		} else {
			for(int j=0 ; j<(int(log10((double)n))) ; j++){
				x/=10;
				if(x){
					if(x%10==3){ 
						cout << " " << i;
						break;
					}
				}
			}
		}		
	}
	cout << endl;
	return 0;
}
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  string s1 = "Hoshino", s2 = "Hoshina";
  string::size_type pos;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    string line;
    getline(cin, line);
    for (pos = line.find(s1); pos != string::npos; pos = line.find(s1, s2.length() + pos))
      line.replace(pos, s1.length(), s2);
    cout << line << endl;
  }

  return 0;
}