Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			fmt.Printf(" %d", Adj[i][j])
			if j == n-1 {
				fmt.Println()
			}
		}
	}
}

C++: #include <iostream>

using namespace std;

const int N = 100;

int main()
{
    int n, c_num, row, column;
    int adj[N][N] = {};
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> row >> c_num;
        for (int j = 0; j < c_num; j++)
        {
            cin >> column;
            adj[row-1][column-1] = 1;
        }
    }

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

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N]; // 0 オリジンの隣接行列
	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--; // 0 オリジンへ変換
		for ( int j = 0; j < k; j++ ) {
			cin >> v;
			v--; // 0 オリジンへ変換
			M[u][v] = 1; // u と v の間に辺を張る
		}
	}
	
	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>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vector<vector<int>> e(n,vector<int>(n,0));
    rep(i,n){
        int a; cin >> a;
        int tmp; cin >> tmp;

        rep(j,tmp) {
            int to; cin >> to;
            e[i][to-1] = 1;
        }
    }

    cout << e << endl;
}

C++: #include <iostream>

using namespace std;

int main() {

  int n;
  cin >> n;
  int A[110][110];
  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 u, k, v;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      A[u-1][v-1] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << ' ';
      cout << A[i][j];
    }
    cout << endl;
  }
}

C++: #include<iostream>
#include<queue>
using namespace std;
int main()
{
  int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  cin>>v;
	  M[u-1][v-1]=1;
	}
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout<<' '<<M[i][j];
    cout<<endl;
  }
  delete M;
}

C++: #include <iostream>
using namespace std;
const int N=100;

int main(){
    //0 0??????????????\??????
    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;
        //??¬??¢???0?????????
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            //??¬??¢???0?????????
            v--;
            //??¨u???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 <iostream>
using namespace std;
static const int N=100;

int main(){
	
	int M[N][N];//定义邻接矩阵 
	
	int n;
	int u,v,k;
	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>0)
				cout<<" ";
			cout<<M[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <queue>
using namespace std;
struct dot{
	long long int k,p,l,r;
};
int main(int argc, char** argv) {
	int n;
	while(cin>>n){
		int d[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				d[i][j]=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			a--;
			for(int j=0;j<b;j++){
				int c;
				cin>>c;
				d[a][c-1]=1;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<d[i][j];
				if(j<n-1)
					cout<<" ";
			}
			cout<<endl;
		}
			
				
	}
	return 0;
}

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


main(){
	int j,m,n,k,i,u;
	int g[101][101];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	    for(j=1;j<=n;j++)
		   g[i][j]=0;
	}
	for(i=1;i<=n;i++){
		scanf("%d%d",&k,&u);
		for(j=0;j<u;j++){
			scanf("%d",&m);
			g[k][m]=1;
		}
	}
	for(i=1;i<=n;i++){
	    for(j=1;j<=n;j++){
		printf("%d",g[i][j]);
		if(j<n)
		printf(" ");}
		printf("\n");
	}
	return 0;
}

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

int main()
{
    int n,k;
    int A[100][100]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int x;
            cin>>x;
            A[i][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>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream> 
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

int A[105][105];

int main(){
    int n;
    cin >> n; cin.ignore();
    for(int i = 1; i <= n; i++){
        string s;
        getline(cin, s);
        istringstream ss(s);
        int u, k, v;
        ss >> u >> k;
        for(int j = 0; j < k; j++){
            ss >> v;
            A[u][v] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            cout << A[i][j];
            if (j != n) cout << " ";
        }
        cout << endl;
    }
}