In the story of “Alibaba and forty robbers”, Alibaba uses his clever wit to overcome the ferocious enemy, and inherits the huge treasure. There are many treasures which is the rectangular net made by pearls, using silver strand to connect each other. Alibaba would like to cut some number of silver strand to make a pearl necklace. Your question is, given the size of pearls net, can Alibaba cut some of silver strand without wasting a pearl to make a pearl necklace(you can wear it in your neck)?

The first line is a positive number C (C <= 1000), which is the number of test data. The following C lines, each line has two positive integers, M, N, represent the pearls net’s height and width respectively, the two integer are separated by a space. (1 <= M <= 1000, 1 <= N <= 1000).

提交代码