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

#QHD0000067. Đồng tiền hai giá trị (e-Coins)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đồng tiền hai giá trị (e-Coins)

e-Coins

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Every electronic coin has two nonnegative components (ai,bi)(a_i,b_i): a conventional value and a technological value. Each coin type is available in unlimited quantities. If the chosen coins contribute total values XX and YY, the e-modulus of the whole selection equals X2+Y2\sqrt{X^2+Y^2}. Add the two components separately before computing the square root. You must not sum individual coin lengths.

Given mm available types and a target integer e-modulus SS, find the minimum number of coins whose total components satisfy X2+Y2=S2X^2+Y^2=S^2. If impossible, print not possible. The zero vector (0,0)(0,0) may be ignored in an optimal solution. Because components are nonnegative, a coin with either component larger than SS cannot be used. Both axis-aligned vectors and vectors with two nonzero components are permitted.

Input

The first line contains m,Sm,S. Each of the next mm lines contains the two nonnegative components ai,bia_i,b_i of a coin type.

Output

Print the minimum number of coins, or exactly not possible if the target e-modulus cannot be obtained.

Subtasks

  • Subtask 1 (20 points): 1≤m≤101\le m\le 10; 1≤S≤301\le S\le 30; each ai,bia_i,b_i is a nonnegative integer up to 10910^9; unlimited coins per type.
  • Subtask 2 (30 points): 1≤m≤251\le m\le 25; 1≤S≤1201\le S\le 120; each ai,bia_i,b_i is a nonnegative integer up to 10910^9; unlimited coins per type.
  • Subtask 3 (50 points): 1≤m≤401\le m\le 40; 1≤S≤3001\le S\le 300; each ai,bia_i,b_i is a nonnegative integer up to 10910^9; unlimited coins per type.

Examples

Input

3 5
3 0
0 4
5 5

Output

2

Explanation

Select (3,0)(3,0) and (0,4)(0,4): totals (X,Y)=(3,4)(X,Y)=(3,4) satisfy 32+42=523^2+4^2=5^2. No single available coin has e-modulus 55, hence two coins are optimal.