#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;

int main(){
	ifstream fin("DATA2.txt");
	ofstream fout("OUT2.txt");
	int pow2[18];
	for(int i=0; i<=17; i++)
		pow2[i] = pow(2.0, i);
	int N;
	for(int T=0; T<5; T++){
		fin>>N;
		for(int i=0; i<17; i++){
			if(N == 0){ 
				fout<<1<<endl;
				break;
			}
			else if(N == pow2[i]){
				fout<<pow2[i]<<endl;
				break;
			}
			else if(N > pow2[i] && N < pow2[i+1]){
				if(abs(N-pow2[i]) < abs(N-pow2[i+1]))
					fout<<pow2[i]<<endl;
				else fout<<pow2[i+1]<<endl;
				break;
			}
		}
	}
	return 0;
}
