PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#TP0000019. Trang bị áo giáp (Dress’em in Vests!)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Trang bị áo giáp (Dress’em in Vests!)

Dress'em in Vests!

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

The Two-Dimensional Kingdom is preparing its army for a conflict. There are nn soldiers; soldier ii requests a bulletproof vest of size aia_i. The armoury contains mm vests; vest jj has size bjb_j.

A soldier accepts some variation in size: soldier ii can wear any vest whose size lies in the inclusive interval [ai−x,ai+y][a_i-x,a_i+y], where x,yx,y are nonnegative integers. Each vest can be assigned to at most one soldier, and each soldier receives at most one vest.

Equip the maximum possible number of soldiers and output the assigned soldier–vest pairs. Soldiers and vests are numbered from 11 in input order. Both input size sequences are already sorted in non-decreasing order.

Input

The first line contains integers n,m,x,yn,m,x,y: the numbers of soldiers and vests, and the two allowed size deviations.

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n in non-decreasing order.

The third line contains mm integers b1,b2,…,bmb_1,b_2,\ldots,b_m in non-decreasing order.

Output

Print one integer kk on the first line: the maximum number of equipped soldiers.

Each of the next exactly kk lines contains two integers u,vu,v, meaning that soldier uu receives vest vv. All soldier indices must be distinct, as must all vest indices. Pairs may appear in any order. Any valid maximum matching is accepted.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤61\le n,m\le 6; 0≤x,y≤1090\le x,y\le10^9; 1≤ai,bj≤1091\le a_i,b_j\le10^9 for every element; a1≤⋯≤ana_1\le\cdots\le a_n, b1≤⋯≤bmb_1\le\cdots\le b_m.
  • Subtask 2 (30 points): 1≤n,m≤20001\le n,m\le 2000; 0≤x,y≤1090\le x,y\le10^9; 1≤ai,bj≤1091\le a_i,b_j\le10^9 for every element; a1≤⋯≤ana_1\le\cdots\le a_n, b1≤⋯≤bmb_1\le\cdots\le b_m.
  • Subtask 3 (50 points): 1≤n,m≤1000001\le n,m\le 100000; 0≤x,y≤1090\le x,y\le10^9; 1≤ai,bj≤1091\le a_i,b_j\le10^9 for every element; a1≤⋯≤ana_1\le\cdots\le a_n, b1≤⋯≤bmb_1\le\cdots\le b_m.

Examples

Input

5 3 0 0
1 2 3 3 4
1 3 5

Output

2
1 1
3 2

Explanation

Since x=y=0x=y=0, a soldier can only wear a vest of exactly the requested size. Vest 11 has size 11 and fits soldier 11. Vest 22 has size 33 and fits soldier 33 (or 44). Vest 33 has size 55 and fits nobody. Therefore at most two pairs can be formed, and the sample prints (1,1)(1,1) and (3,2)(3,2).