#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> prices[1010];   int allp[1010];   int all;   int margin_price;   int above_cnt[1010], margin_cnt[1010], cnt[1010];   double f[1010][1010], g[1010][1010];   double comb[1010][1010];   int main() {     comb[1][0] = comb[1][1] = 1;     for (int i = 2; i <= 1000; i++) {       comb[i][0] = comb[i][i] = 1;       for (int j = 1; j < i; j++)         comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];     }     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int k;       scanf( %d , &k);       while (k--) {         int v;         scanf( %d , &v);         prices[i].push_back(v);         allp[++all] = v;       }     }     sort(allp + 1, allp + all + 1);     reverse(allp + 1, allp + all + 1);     margin_price = allp[n];     int need_margin = 0;     for (int i = 1; i <= n; i++)       if (allp[i] == margin_price) need_margin++;     for (int i = 1; i <= m; i++) {       for (int p : prices[i]) {         if (p > margin_price)           above_cnt[i]++;         else if (p == margin_price)           margin_cnt[i]++;         cnt[i]++;       }     }     f[0][0] = 1;     g[0][0] = 1;     for (int i = 1; i <= m; i++) {       for (int j = 0; j <= need_margin; j++) {         if (margin_cnt[i] == 0) {           f[i][j] += f[i - 1][j] / comb[cnt[i]][above_cnt[i]];           g[i][j] += g[i - 1][j];         } else if (margin_cnt[i] == 1) {           f[i][j] += f[i - 1][j] / comb[cnt[i]][above_cnt[i]];           g[i][j] += g[i - 1][j];           f[i][j + 1] += f[i - 1][j] / comb[cnt[i]][above_cnt[i] + 1];           g[i][j + 1] += g[i - 1][j];         } else {           assert(false);         }       }     }     printf( %.15f n , f[m][need_margin] / g[m][need_margin]);     return 0;   }   