SP20644 ZQUERY - Zero Query

Description

[English](/problems/ZQUERY/en) [Vietnamese](/problems/ZQUERY/vn)Given an array having **N** elements, each element is either **-1** or **1**. You have **M** queries, each query has two numbers **L** and **R**, you have to answer the length of the longest subarray in range **L** to **R** (inclusive) that its sum is equal to 0.

Input Format

The first line contains two numbers **N** and **M** (**1**

Output Format

For each query, print the length of the longest subarray that satisfies the query in one line. If there isn't any such subarray, print 0.