For given string ‘str’ of digits, find length of the **longest** substring of ‘str’, such that the length of the substring is 2k digits and sum of left k digits is equal to the sum of right k digits.

**Input:**

The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.

Each test case contains a string string of length N.

**Output:**

Print length of the longest substring of length 2k such that sum of left k elements is equal to right k elements and if there is no such substring print 0.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 100

**Example:**

Input:

2

000000

1234123

Output:

6

4

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.

Akkki111 | 38 |

SaltBaeSama | 34 |

ambercyrus | 33 |

LegendFire | 32 |

chocozz | 32 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1219 |

mazumderrohit8 | 1095 |

SumitSingh27 | 1090 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4566 |

Quandray | 4444 |

Login to report an issue on this page.