There are N identical bags out of which there is a big diamond hidden in one bag, you need to find in which bag diamond is hidden. You have one balance scale and you know that the bag having the diamond is heavier than other bags.

You can put as many bags as possible at a time and measure weight but you have to figure out number of bags you will put first time (on one side) so that you will use scale minimum number of times.

**Input:**

The first line of the input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing an integer N, that denotes the number of bags.

**Output:**

For each test case, print in a new line, the minimum number of times you need to use the balance scale.

**Constraints:**

1 <= T <= 10^{3}

1 <= N <= 10^{6}

**Examples:
Input:**

2

2

3

1

1

**Explanation:**

There are two test cases:

1) When N=2 we can just compare and see which bag is heavier and has the diamond.

2) When N=3 we can just take any two bags and the one which is heavier has the diamond if both weigh same then the third bag has the diamond.

So in both cases we put 1 bag on each side and weigh only once.

Author: sd5869

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

devsinghindra | 80 |

PiyushPandey4 | 614 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 443 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.