Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

C++: #include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int judge(int i, int n, int variable, vector< vector<int> > &v)
{
	for (int j = 0; j<v[variable].size(); ++j) {
		if (i == v[variable][j]) {
			return 1;
			break;
		}
	}
	return 0;
}
int main()
{
	int n, u, k, vv;
	cin >> n;
	vector< vector<int> > v(n), a(n, vector<int>(n));
	for (int variable = 0; variable<n; ++variable) {
		cin >> u >> k;
		for (int i = 0; i<k; ++i) {
			cin >> vv;
			v[variable].push_back(vv);
		}
	}
	for (int variable = 0; variable<n; ++variable)
		for (int i = 1; i <= n; ++i)
			a[variable][i - 1] = judge(i, n, variable, v);
	for (int variable = 0; variable<n; ++variable)
		for (int i = 0; i<n; ++i)
			printf("%d%c", a[variable][i], i == n - 1 ? "\n" : " ");
}

C++: 
#include <iostream>
using namespace std;
int main() {
    int n,p,q,x;
    cin>>n;
    int A[100][100]={0};
    for (int i=0;i<n;i++){
        cin>>q>>p;
        if (p==0)
            continue;
        for (int j=0;j<p;j++){
            cin>>x;
            A[q][x-1]=1;
        }
    }
    
    
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            cout<<A[i][j];
            if (j!=n-1)cout<<" "; 
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main ()
{
    int N;
    cin >> N;

    int M[N][N];

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << " " << M[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#define MAX 120
using namespace std;

int main() {
   // freopen("in.txt", "r", stdin);

    int n, u, k, v;
    int graph[MAX][MAX];
    cin >> n;

    // init
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            graph[i][j] = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            graph[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << graph[i][j];
            if (j != n) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 2; j < n; j++)
	{
	  if (ln[i][j] != 0 )
	    {
	      m[i][ln[i][j]-1] = 1;
	    }
	}
    }
  for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
	{
	  cout << m[i][j] << " ";
	}
      cout << endl;
    }
  return 0;
}

C++: #include <stdio.h>

int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110];

void get_map();
void print_map();
void conv_map();
void print_mat();

int main()
{

  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}

void get_map()
{

  int k;
  scanf("%d", &map_max);//<100

  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
	{
	  map[i-1][j-1]=0;
	  scanf("%d", &map[i-1][j-1]);
	}
    }

  
  return ;
}

void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  printf("%d", map[i-1][j-1]);
	}
      puts("");
    }
return ;
}


void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
	{
	  mat[i][map[i-1][j-1]-1]=1;
	}
    }
  return ;
}

void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
	{
	  printf("%d", mat[i][j]);
	  if(j!=map_max-1)
	    {
	      printf(" ");
	    }
	}
      if(i!=map_max-1)
	{
      printf("\n");
	}
    }
}

C++: #include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector< vector<bool> > ans(n, vector<bool>(n, false));
    rep(i, n){
        int u, k;
        cin >> u >> k;
        --u;
        rep(j, k){
            int v;
            cin >> v;
            ans[u][--v] = true;
        }
    }

    rep(i, n){
        rep(j, n){
            if(j) cout << ' ';
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <set>
#include <vector>
#include <utility>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int g[101][101],n;

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        int u,k,v;
        cin >> u >> k;
        for(int j = 0;j < k;j++) {
            cin >> v;
            g[u][v]++;
        }
    }
    for(int i = 1;i <= n;i++){for(int j = 1;j <n;j++)cout<<g[i][j] << " "; cout<<g[i][n] << endl;}
}

C++: #include<iostream>
using namespace std;

int main()
{
	int i,j,n,u,k;
	int v[100][100];
	cin >> n;
	for(i=0;i<n;i++){
		cin >> u;
		for(j=0;j<u;j++){
			cin >> k;
			cin >>v[i][k];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cout << v[i][j] << " ";
		}
		cout<<endl;
	}
}