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.util.*;
  import java.lang.*;
  import java.io.*;
  /**
  * @author zeel prajapati
   */
  // public class Main{
  final public class Solution{
  static int max=Integer.MAX_VALUE;
  static int min=Integer.MIN_VALUE;
  public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  
   ArrayList<Integer> ans=new ArrayList<>();
   int c=0,nu=0;
   while(c!=1000){
       if(nu%3==0 || nu%10==3){
           nu++;
           continue;
       }
       ans.add(nu);
       c++;
       nu++;
   }
   int t=Integer.parseInt(br.readLine());
   while(t-->0){
      int n=Integer.parseInt(br.readLine());
      System.out.println(ans.get(n-1));
  
   }
  }
  
  
  public static int[] Inputarr(BufferedReader br){
      try{
      String s=br.readLine();
      String d[]=s.split(Character.toString(' '));
      int n=d.length;
      
      int arr[]=new int[n];
      for(int i=0;i<n;i++){
          arr[i]=Integer.parseInt(d[i]);
      }
          return arr;
      }catch(IOException e){
       System.out.println(1); 
      }
      return new int[1];
  }
  
  public static void printarr(int arr[]){
      StringBuffer br=new StringBuffer();
      for(int i=0;i<arr.length;i++){
          br.append(arr[i]+Character.toString(' '));
      }
      System.out.println(br);
  }
  }
  class Node{
  int i,j,value;
  Node(int i,int j,int v){
  this.i=i;
  this.j=j;
  this.value=v;
  }
  }
  class com implements Comparator<Integer>{
  @Override
  public int compare(Integer arg0, Integer arg1) {
  return arg1-arg0;
  }
  }