description: Polycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.
  
  Polycarp starts to write out the positive (greater than 0) integers which he likes: 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, .... Output the k-th element of this sequence (the elements are numbered from 1).
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.
  
  Each test case consists of one line containing one integer k (1 ≤ k ≤ 1000).
  
  Output
  
  For each test case, output in a separate line one integer x — the k-th element of the sequence that was written out by Polycarp.
  
  Example
  
  Input
  
  
  10
  1
  2
  3
  4
  5
  6
  7
  8
  9
  1000
  
  
  Output
  
  
  1
  2
  4
  5
  7
  8
  10
  11
  14
  1666
solution: 
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.StringTokenizer;
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.TreeSet;
  
  import java.util.Iterator;
  
  public class First {
  
  	public static void main(String[] args) {
  		FastScanner fs = new FastScanner();
  		int T = fs.nextInt();
  		int[] arr=new int[1001];
  		int x=1;
  		int j=1;
  		while(j<=1000)
  		{
  			arr[j++]=x;
  			x++;
  			String s=String.valueOf(x);
  			char c=s.charAt(s.length()-1);
  			
  			while(x%3==0 || c=='3')
  			{
  				x++;
  				s=String.valueOf(x);
  				c=s.charAt(s.length()-1);
  			}
  		
  		}
  		//debug1(arr);
  		for (int tt = 0; tt < T; tt++) {
  
  			int y=fs.nextInt();
  
  			System.out.println(arr[y]);
  		}
  	}
  	static int solve()
  	{
  		return 0;
  	}
  	static int MOD=(int)(1e9+7);
      static void debug1(int[] arr)
      {
          for(int i=0;i<arr.length;++i)
              System.out.print(arr[i]+" ");
          System.out.println();
      }
      static void debug2(int[][] arr)
      {
          for(int i=0;i<arr.length;++i)
          	for(int j=0;j<arr[0].length;++j)
          		System.out.println(arr[i][j]+" ");
          System.out.println();
      }
  
      static int[] take1(int n, FastScanner fs)
      {
          int[] arr=new int[n];
          for(int i=0;i<n;++i)
              arr[i]=fs.nextInt();
          return arr;
      } 
      static int[][] take2(int m, int n, FastScanner fs)
      {
          int[][] arr=new int[m][n];
          for(int i=0;i<m;++i)
              for(int j=0;j<n;++j)
                  arr[i][j]=fs.nextInt();
          return arr;
      } 
  	static class FastScanner {
  		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st = new StringTokenizer("");
  		String next() {
  			while (!st.hasMoreTokens())
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			return st.nextToken();
  		}
  
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		int[] readArray(int n) {
  			int[] a = new int[n];
  			for (int i = 0; i < n; i++) a[i] = nextInt();
  			return a;
  		}
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
  
  
  }