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.*;
  
  import java.util.*;
  
  public class Main {
      static class Scanner{
          BufferedReader br ;
          StringTokenizer st;
          Scanner(){
              br = new BufferedReader(new InputStreamReader(System.in));
              st = new StringTokenizer("");
          }
          String next() throws IOException {
              while(!st.hasMoreElements()){
                  st = new StringTokenizer(br.readLine());
              }
              return st.nextToken();
          }
          String nextLine() throws IOException{
              return br.readLine();
          }
          int nextInt() throws  IOException{
              return Integer.parseInt((next()));
          }
          boolean isReady() throws IOException {
              return br.ready();
          }
      }
      static PrintWriter pw = new PrintWriter(System.out);
      public static final long inf =(int)2e15;
      public static int gcd(int x,int y){
          if(x==0||y==0)return 0;
          while (x!=y){
              if(x>y){
                  x-=y;
              }
              else y-=x;
          }
          return x;
      }
  
      public static class pair implements Comparable<pair>{
          long u,v;
          public pair(long u,long v) {
              this.u = u;
              this.v = v;
          }
  
          @Override
          public String toString() {
              return "("+u+" "+v+")";
          }
  
          @Override
          public int compareTo(pair o) {
              return Long.compare(u,o.u);
          }
      }
      public static class triple implements Comparable<triple>{
          int u,v,w;
          public triple(int u,int v,int w) {
              this.u = u;
              this.w = w;
              this.v = v;
          }
  
          @Override
          public String toString() {
              return "("+u+" "+v+")";
          }
  
          @Override
          public int compareTo(triple o) {
              return w - o.w;
          }
      }
      static void make_set(int n,int[]parent,int[]size){
          for(int i=0;i<n;i++){
              parent[i] = i;
              size[i] = 1;
          }
      }
      static int find_parent(int v,int parent[],int[]size){
          if(parent[v]!= v) return parent[v] = find_parent(parent[v],parent,size);
          return v;
      }
      static void union_set(int a, int b,int[]parent,int[]size){
          a = find_parent(a,parent,size);
          b = find_parent(b,parent,size);
          if(a==b) return ;
          if(size[a] == size[b]){
              int tmp = b;
              b = a; a= tmp;
          }
          parent[b] = a;
          size[a]+= size[b];
      }
      public static void main(String[] args) throws IOException, InterruptedException {
          Scanner sc = new Scanner();
          int t = sc.nextInt();
          int[] arr = new int[1010];
          int index = 0;
          int count = 1;
          while(index!=1010){
              if(count%10!=3&&count%3!=0){
                  arr[index++] = count;
              }
              count++;
          }
          while(t-->0){
              pw.println(arr[sc.nextInt()-1]);
          }
          pw.close();
      }
  
  }
  
  