Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.

The main exhibit is a construction of *n* matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to *n*. A matryoshka with a smaller number can be nested in a matryoshka with a higher number, two matryoshkas can not be directly nested in the same doll, but there may be chain nestings, for example, 1 → 2 → 4 → 5. 

In one second, you can perform one of the two following operations:
 -  Having a matryoshka *a* that isn't nested in any other matryoshka and a matryoshka *b*, such that *b* doesn't contain any other matryoshka and is not nested in any other matryoshka, you may put *a* in *b*; -  Having a matryoshka *a* directly contained in matryoshka *b*, such that *b* is not nested in any other matryoshka, you may get *a* out of *b*. 
According to the modern aesthetic norms the matryoshka dolls on display were assembled in a specific configuration, i.e. as several separate chains of nested matryoshkas, but the criminal, following the mysterious plan, took out all the dolls and assembled them into a single large chain (1 → 2 → ... → *n*). In order to continue the investigation Andrewid needs to know in what minimum time it is possible to perform this action.
The first line contains integers *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) and *k* (1 ≤ *k* ≤ 10<sup class="upper-index">5</sup>) — the number of matryoshkas and matryoshka chains in the initial configuration.

The next *k* lines contain the descriptions of the chains: the *i*-th line first contains number *m*<sub class="lower-index">*i*</sub> (1 ≤ *m*<sub class="lower-index">*i*</sub> ≤ *n*), and then *m*<sub class="lower-index">*i*</sub> numbers *a*<sub class="lower-index">*i*1</sub>, *a*<sub class="lower-index">*i*2</sub>, ..., *a*<sub class="lower-index">*im*<sub class="lower-index">*i*</sub></sub> — the numbers of matryoshkas in the chain (matryoshka *a*<sub class="lower-index">*i*1</sub> is nested into matryoshka *a*<sub class="lower-index">*i*2</sub>, that is nested into matryoshka *a*<sub class="lower-index">*i*3</sub>, and so on till the matryoshka *a*<sub class="lower-index">*im*<sub class="lower-index">*i*</sub></sub> that isn't nested into any other matryoshka).

It is guaranteed that *m*<sub class="lower-index">1</sub> + *m*<sub class="lower-index">2</sub> + ... + *m*<sub class="lower-index">*k*</sub> = *n*, the numbers of matryoshkas in all the chains are distinct, in each chain the numbers of matryoshkas follow in the ascending order.
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <random>
#include <stack>
using namespace std;
 
typedef long long ll;
 
stack <time_t> time_stack;
void startTimer()
{
        time_stack.push(clock());
}
double stopTimer()
{
        double time = clock() - time_stack.top();
        time_stack.pop();
        return time / double(CLOCKS_PER_SEC);
}
 
 
#define MAXN 1e5
#define INF 2140000000
#define MOD 1000000007
#define EPS double(1e-7)
#define PI 3.14159265359
 
 
 struct Sphere
 {
     int x, y, z, r, id;
 };
 
 struct Point
 {
     double x, y, z;
 };
 
 
int main()
{
        ios::sync_with_stdio(false);
#ifdef _HOME_
        ifstream cin("input.txt");
        ofstream cout("output.txt");
#else
        //freopen(TASK ".in", "r", stdin);
        //freopen(TASK ".out", "w", stdout);
#endif
 
         
         int n;
         vector <Sphere> a(n);
         for (int i = 0; i < n; i++)
         {
             cin >> a[i].x >> a[i].y >> a[i].z >> a[i].r;
             a[i].id = i;
         }
         
         Point p1, p2;
         cin >> p1.x >> p1.y >> p1.z >> p2.x >> p2.y >> p2.z;
         for (int i = 0; i < 10; i++)
         {
             double a = p2.x - p1.x,
                 b = p2.y - p1.y,
                 c = p2.z - p1.z;
             
             vector <Sphere> intersect;
             for (int j = 0; j < n; j++)
             {
                 double d = p1.x - a[j].x,
                     e = p1.y - a[j].y,
                     f = p1.z - a[j].z;
             }
         }
 
#ifdef _HOME_
        system("pause");
#endif
 
        return 0;
}