This page is still under construction.

Parts of this page are still being built. What you see may change.

Why-Salesman Tour

Time limit9sMemory limit256 MB

Summary
Decide whether a metric graph with up to 14 vertices has a Hamiltonian cycle of total length exactly L.
Level

Medium7 of 10

Topics
Dynamic programming, Bit manipulation, Graph
Solved
No attempts yet

Problem

Hyunwoo has plenty of complaints about his job as a traveling salesman. He now calls himself a why-salesman instead.

The traveling salesman problem asks for the shortest route that visits every vertex of a graph once and returns to the start. The why-salesman problem has a different goal. In a graph with NN vertices, decide whether some route that visits every vertex once and returns to the start has length exactly LL. In other words, decide whether a cycle of size NN and length LL exists.

If N=2N = 2, the tour that goes from one vertex to the other and back has length 2d122d_{12}.

Input

The first line contains the number of vertices NN and the target distance LL. (2≤N≤142 \le N \le 14, 1≤L≤10151 \le L \le 10^{15})

Each of the next NN lines gives the distances between vertices. The jj-th value on the ii-th line is the distance dijd_{ij} between vertex ii and vertex jj. If i≠ji \ne j then 1≤dij≤L1 \le d_{ij} \le L, and dii=0d_{ii} = 0 for every ii. For all 1≤i,j,k≤N1 \le i, j, k \le N, dij=djid_{ij} = d_{ji} and dij≤dik+dkjd_{ij} \le d_{ik} + d_{kj}.

Output

Print possible on the first line if a cycle of size NN and length LL exists, and impossible otherwise. Print it without the quotation marks.

Examples2

  1. Example 1

    Input
    4 10
    0 3 2 1
    3 0 1 3
    2 1 0 2
    1 3 2 0
    
    Expected output
    possible
    
  2. Example 2

    Input
    3 5
    0 1 2
    1 0 3
    2 3 0
    
    Expected output
    impossible