# Prefix Sum

Given an array A and an index i, the prevfix sums array P is accumulated sums calculated over [0] … [i]

Prefix sums can be used to get sums of any arbitrary length subarray.

## Subarray Sums II

Subarray Sums II

Given an array of n integers, your task is to count the number of subarrays having sum x.

Input

The first input line has two integers n and x: the size of the array and the target sum x.

The next line has n integers a1,a2,…,an: the contents of the array.

Output

Print one integer: the required number of subarrays.

Constraints
1≤n≤2⋅105
−109≤x,ai≤109
Example

Input:

5 7
2 -1 3 5 -2


Output:

2


## Subarray Divisibility

Subarray Divisibility

Given an array of n integers, your task is to count the number of subarrays where the sum of values is divisible by n

Input

The first input line has an integer n: the size of the array.

The next line has n integers a1,a2,…,an: the contents of the array.

Output

Print one integer: the required number of subarrays.

Constraints
1≤n≤2⋅105
−109≤ai≤109
Example

Input:

5
3 1 2 7 4


Output:

1


### Find Pivot Index

Find Pivot Index

Given an array of integers nums, write a method that returns the “pivot” index of this array.

We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index.

If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.

### Subarray Sums Divisible by K

Leetcode Subarray Sums Divisible by K

Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.

Input: A = [4,5,0,-2,-3,1], K = 5
Output: 7
Explanation: There are 7 subarrays with a sum divisible by K = 5:
[4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]

### Forest Queries (2D PrefixSum)

Forest Queries

You are given an n×n grid representing the map of a forest. Each square is either empty or contains a tree. The upper-left square has coordinates (1,1), and the lower-right square has coordinates (n,n).

Your task is to process q queries of the form: how many trees are inside a given rectangle in the forest?

Input

The first input line has two integers n and q: the size of the forest and the number of queries.

Then, there are n lines describing the forest. Each line has n characters: . is an empty square and * is a tree.

Finally, there are q lines describing the queries. Each line has four integers y1, x1, y2, x2 corresponding to the corners of a rectangle.

Output

Print the number of trees inside each rectangle.

Constraints
1≤n≤1000
1≤q≤2⋅105
1≤y1≤y2≤n
1≤x1≤x2≤n
Example

Input:

4 3
.*..
*.**
**..
****
2 2 3 4
3 1 3 1
1 1 2 2


Output:  3 1 2 `