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>
using namespace std;
static const int N=100;
int main()
{
    int M[N][N];
    int n,u,k,v;
    cin>>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++)
    {
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++)
        {
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(j) cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}

C++: //16D8104001K 田中誠人 makoto0106 c++
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  std::vector<int>num;
  int n,k,tmp,x,size;

  std::cin>>n;
  
  for(int i=0;i<n;i++){
    std::cin>>tmp>>k;
    num.push_back(k);
    for(int j=0;j<k;j++){
      std::cin>>tmp;
      num.push_back(tmp);
      //std::cout<<tmp<<" ";
    }
  }
  size=num.size();
  /*
  for(int i=0;i<size;i++){
    std::cout<<num[i]<<" ";
  }
  */
  x=0;
 
  while(x<size){
    if(num[x]==0){
      for(int i=0;i<n;i++){
	std::cout<<"0 ";
      }
      x++;
    }else{
      x++;
      for(int i=0;i<n;i++){
      
	if(i+1==num[x]){
	  std::cout<<"1 ";
	  x++;
	}else{
	  std::cout<<"0 ";
	}
      }
    }
    std::cout<<"\n";
  }
  
  
  return 0;
}

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

int main(){
  int n, u, k, x;
  int m[100][100]={0};

  cin >> n;

  for (int i=1; i<=n; i++){
    cin >> u >> k;
    for (int j=1; j<=k; j++){
      cin >> x;
      m[i][x]=1;
    }
  }

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

  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef float fl;
typedef long long ll;
int n;
int a[101][101];

int main(){
    cin >> n;
    rep(i,n){
        int u, k; cin >> u >> k;
        rep(j,k){
            int l; cin >> l;
            a[i][l-1] = 1;
        }
    }
    
    rep(i,n){
        rep(j,n){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 110;
int n;
int G[MAX][MAX];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    memset(G, 0, sizeof(G));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int p, k;
        scanf("%d %d", &p, &k);
        while (k--) {
            int ne = 0;
            scanf("%d", &ne);
            G[p][ne] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j > 1) printf(" ");
            printf("%d", G[i][j]);
        }
        printf("\n");
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
using namespace std;
int  v[102][101], n;
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j) cout << " ";
			cout << v[i][j];
		}
		cout << endl;
	}	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int mat[n][n] = {};

    for(int i = 0; i < n; i++){
        int x, k, y;
        cin >> x >> k;
        while(k-- > 0){
            cin >> y;
            mat[x-1][y-1] = 1;
        }
    }

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

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	int M[105][105];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			M[i][j]=0;
		}
		
	}
	int h,p,e;
	for(int i=0;i<n;i++){
		cin>> h>>p;
		h--;
		for(int j=0;j<p;j++){
			cin>>e;
			e--;
			M[h][e]=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j){
				printf(" ");
			}
			printf("%d",M[i][j]);
		}
		cout <<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	int n,u,k,v;
	cin >> n;
	int m[100][100];
	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++) {
		cin >> u >> k;u--;
		for (int j = 0;j < k;j++) {
			cin >> v; v--;
			m[u][v] = 1;
		}
	}
	for (int i = 0; i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (j)cout << " ";
			cout << m[i][j];
		}
		cout << endl;
	}
}

C++: #include<bits/stdc++.h>

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define ll long long
#define bpm %1000000007

using namespace std;

ll powAns(ll,ll);

int main(){
    int n,u,k;
    int a;
    cin>>n;
    int vec[n][n];

    rep(i,n)rep(j,n)vec[i][j]=0;

    rep(i,n){
        cin>>u>>k;
        rep(j,k){
            cin>>a;
            vec[u-1][a-1]=1;
        }
    }
    rep(i,n){
        rep(j,n-1)cout<<vec[i][j]<<" ";
        cout<<vec[i][n-1]<<endl;
    }
}

ll powAns(ll m ,ll n){
    ll res=1;
    while(n>0){
        if(n & 1)res = res*m bpm;

        m=m*m bpm;
        n>>=1;
    }

    return res;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 110

using namespace std;

static const int N = 110;

int main(){
    int n;//頂点数
    cin >> n;

    int Adj[MAX];
    int M[N][N];
    
    int u;
    int k;
    int v;
    
    for(int i=1; i<=n; i++){
        M[i][i] = 0;
    }
    
    
    for(int j=1; j<=n; j++){
        cin >> u >>k;
        for(int a=1; a<=k; a++){
            cin >> v;
            Adj[v] = 1;
            
            if(Adj[v] != 0){
            M[u][v] = 1;
            }
        }
         
        
    }
    
    for(int j=1;j<=n; j++){
        for(int i=1; i<=n; i++){
            if(i != 1){
                cout << " ";
            }
            cout << M[j][i];
        }
        
        cout << endl;
        
    
    }
    
    
    
    return 0;
    
}