Given an odd-digit-number N, you need to find whether the given number is a balanced-number or not. An odd digit number is called a balanced number if the sum of all digits to the left of the middle digit and the sum of all digits to the right of the middle digit is equal.

**Input:**

The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows, a single line of the input containing a positive integer N.

**Output:**

For each test-case, print 0 if the number is not balanced, and 1 if the number is balanced.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{20}

**Example:**

**Input:**

5

121

1234006

19091

12345

90988

**Output:**

1

1

1

0

0

**Explanation:**

For testcase 1: 121.

The number of digits of 121 is 3, i.e. odd digits. The middle digit is 2. LHS sum is 1, and RHS sum is 1.

Since the sums are equal, we output 1.

For testcase 2: 1234006.

The number of digits of 1234006. is 7, i.e. odd digits. The middle digit is 4. LHS sum is 1+2+3=6, and RHS sum is 0+0+6=6.

Since the sums are equal, we output 1.

Author: Soul_xhacker

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 |

madhursengar24 | 86 |

PiyushPandey4 | 617 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 448 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.