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>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> A(n*n,0);

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

    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i*n+j];
            if(j<n-1){
                cout << " ";
            } else {cout << endl;}
        }
    }
    return 0;
}

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++: #include <iostream>
using namespace std;
#define MAX 101

int main(void){
  int n, u, k, v, Adj[MAX][MAX];
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> u >> k;
    //cout << u << " " << k << endl;
    for(int j=1; j<=n; j++){
      Adj[i][j] = 0;
      //if(j-1) cout << " ";
      //cout << Adj[i][j];
    }
    //cout << endl;
    for(int j=0; j<k; j++){
      cin >> v;
      //cout << (j ? " " : "") << v;
      Adj[u][v] = 1;
    }
    //cout << endl;
    for(int j=1; j<=n; j++){
      if(j-1) cout << " ";
      cout << Adj[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> Adj[n];
    //input_graph
    int u, k, v;
    for(int i=0; i<n; i++){
        std::cin >> u >> k;
        for(int j=0; j<k; j++){
            std::cin >> v;
            Adj[u-1].push_back(v);
        }
    }

    //input_A
    int A[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            A[i][j] = 0;
        }
    }
    for(int i=0; i<n; i++){
        int len = Adj[i].size();
        for(int j=0; j<len; j++){
            A[i][Adj[i][j]-1] = 1;
        }
    }

    //output_A
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j+1==n)  std::cout << A[i][j] << '\n';
            else        std::cout << A[i][j] << " ";
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int n,m,x,a;
    in(n);
    vector2d(int,graph,n,n,0);
    rep(i,n){
        in(a,m);
        rep(j,m){
            in(x);
            //debug(x);
            graph[a-1][x-1]=1;
        }
    }
    rep(i,n)out(graph[i]);
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> mat(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int v;
            cin >> v;
            mat.at(u-1).at(v-1)=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << mat.at(i).at(j);
            if(j==n-1) cout << endl;
            else cout << " ";
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;


int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0 << ' ';
      else cout << v[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}