#abc265f. [abc265_f]Manhattan Cafe

[abc265_f]Manhattan Cafe

Problem Statement

In an NN-dimensional space, the Manhattan distance d(x,y)d(x,y) between two points x=(x1,x2,dots,xN)x=(x_1, x_2, \\dots, x_N) and y=(y1,y2,dots,yN)y = (y_1, y_2, \\dots, y_N) is defined by:

$\\displaystyle d(x,y)=\\sum_{i=1}^n \\vert x_i - y_i \\vert.$

A point x=(x1,x2,dots,xN)x=(x_1, x_2, \\dots, x_N) is said to be a lattice point if the components x1,x2,dots,xNx_1, x_2, \\dots, x_N are all integers.

You are given lattice points p=(p1,p2,dots,pN)p=(p_1, p_2, \\dots, p_N) and q=(q1,q2,dots,qN)q = (q_1, q_2, \\dots, q_N) in an NN-dimensional space.
How many lattice points rr satisfy d(p,r)leqDd(p,r) \\leq D and d(q,r)leqDd(q,r) \\leq D? Find the count modulo 998244353998244353.

Constraints

  • 1leqNleq1001 \\leq N \\leq 100
  • 0leqDleq10000 \\leq D \\leq 1000
  • \-1000leqpi,qileq1000\-1000 \\leq p_i, q_i \\leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN DD p1p_1 p2p_2 dots\\dots pNp_N q1q_1 q2q_2 dots\\dots qNq_N

Output

Print the answer.


Sample Input 1

1 5
0
3

Sample Output 1

8

When N=1N=1, we consider points in a one-dimensional space, that is, on a number line.
88 lattice points satisfy the conditions: \-2,1,0,1,2,3,4,5\-2,-1,0,1,2,3,4,5.


Sample Input 2

3 10
2 6 5
2 1 2

Sample Output 2

632

Sample Input 3

10 100
3 1 4 1 5 9 2 6 5 3
2 7 1 8 2 8 1 8 2 8

Sample Output 3

145428186