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.ArrayList;
  import java.util.Arrays;
  import java.util.Random;
  import java.util.StringTokenizer;
  
  public class A {
  
      public static void main(String[] args) {
          FastReader scan = new FastReader();
          PrintWriter out = new PrintWriter(System.out);
          Task solver = new Task();
          int t = 1;
          for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
          out.close();
      }
  
      static class Task {
  
          public void solve(int testNumber, FastReader scan, PrintWriter out) {
              ArrayList<Integer> have = new ArrayList<>();
              int at = 1;
              while(have.size() < 1000) {
                  boolean a = check1(at), b = check2(at);
                  if(a && b) have.add(at);
                  at++;
              }
              int n = scan.nextInt();
              while(n-->0) out.println(have.get(scan.nextInt() - 1));
          }
  
          boolean check1(int x) {
              return x % 3 != 0;
          }
  
          boolean check2(int x) {
              return x % 10 != 3;
          }
  
      }
  
      static void ruffleSort(int[] a) {
          Random get = new Random();
          for (int i = 0; i < a.length; i++) {
              int r = get.nextInt(a.length);
              int temp = a[i];
              a[i] = a[r];
              a[r] = temp;
          }
          Arrays.sort(a);
      }
  
      static void ruffleSort(long[] a) {
          Random get = new Random();
          for (int i = 0; i < a.length; i++) {
              int r = get.nextInt(a.length);
              long temp = a[i];
              a[i] = a[r];
              a[r] = temp;
          }
          Arrays.sort(a);
      }
  
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          public FastReader(String s) throws FileNotFoundException {
              br = new BufferedReader(new FileReader(new File(s)));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  
  }