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++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long double lb;

const int INF=1<<27;
const int MOD=(int)1e9+7;

int main(void)
{
    int n, u, v, k, a[101][101]={0}, adj[101];

    cin >> n;
    rep(i,n){
        cin >> u >> k;
        rep(i,k){
            cin >> v;
            a[u][v] = 1;
        }
    }

    rep(i,n){rep(j,n) cout << a[i+1][j+1] << ' '; cout << endl;}
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	cin >> n;

	int G[100][100] = {};
	for(int i=0; i<n; i++){
		int u,k;
		cin >> u >> k;
		for(int l=0; l<k; l++){
			int v;
			cin >> v;
			G[u-1][v-1] = 1;
		}
	}

	for(int i=0; i<n; i++){
		for(int l=0; l<n; l++){
			cout << G[i][l];
			if(l==n-1){
				cout << endl;
			}
			else{
				cout << " ";
			}
		}
	}

	return 0;
}

C++: #include<stdio.h>
#include<cstdlib>

#define MAX 100

int main(){
  int i, j, n, m, a, b[MAX+1][MAX+1];

  
  scanf("%d", &n);

  for(i = 1; i < n+1; i++){
    for(j = 1; j < n+1; j++){
      b[i][j] = 0;
    }
  }
  for(i = 1; i <= n; i++){
    scanf("%d %d", &m, &m);
    for(j = 1; j <= m; j++){
      scanf("%d", &a);
      //printf("b[%d][%d]:1\n", i, a);
      b[i][a] = 1;
    }
  }

  
  for(i = 1; i < n+1; i++){
    for(j = 1; j < n; j++){
      printf("%d ", b[i][j]);
    }
    printf("%d\n", b[i][n]);
    }

  
  return 0;
}

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

int main(){
    int n;cin>>n;
    int adj[n][n];
    rep(i,n)rep(j,n)adj[i][j]=0;
    rep(i,n){
        int node,k,id;
        scanf("%d %d",&node,&k);
        node--;
        rep(j,k){
            scanf("%d",&id);
            id--;
            adj[node][id]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            if(j!=0)printf(" ");
            printf("%d",adj[i][j]);
        }
        printf("\n");
    }
}

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

C++: #include <stdio.h>
int main(){
  int i, j;
  int n, u, k, v;
  int A[101][101];
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      A[i][j]=0;
    }
  }
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &u);
    scanf("%d", &k);
    for( j = 0 ; j < k ; j++ ){
      scanf("%d", &v);
      A[u-1][v-1]=1;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++){
      printf("%d",A[i][j]);
      if( j < n - 1 ){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

const int N = 100 + 1;

int main() {
    int A[N][N] = {{0}};

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u;
        cin >> u;

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

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

    return 0;
}

C++: #include<cstdio>

void InitializeIntegerMatrix(int nmbr_of_rows, int nmbr_of_columns, int m[][100]){
	for (int row = 0; row < nmbr_of_rows; ++row) {
		for (int column = 0; column < nmbr_of_columns; ++column)
			m[row][column] = 0;
	}
}

void ListToMatrix(int number_of_vertices, int adjmtr[][100]){
	int vertex_from, vertex_to, degree_out;	
	for (int vertex_i = 0; vertex_i < number_of_vertices; ++vertex_i) {
		scanf("%d %d", &vertex_from, &degree_out);
		vertex_from--; //0?????????????????????
		for (int vertex_out_i = 0; vertex_out_i < degree_out; ++vertex_out_i) {
			scanf("%d", &vertex_to);
			vertex_to--; //0?????????????????????
			adjmtr[vertex_from][vertex_to] = 1;
		}
	}
}

void PrintIntegerMatrix(int nmbr_of_rows, int nmbr_of_columns, int mtr[][100]){
	for (int row = 0; row < nmbr_of_rows; ++row) {
		for (int column = 0; column < nmbr_of_rows; ++column) {
			if(column > 0)
				printf(" ");
			printf("%d", mtr[row][column]);
		}
		printf("\n");
	}
}

int main(void){
	int number_of_vertices;
	scanf("%d", &number_of_vertices);
	int n = number_of_vertices;
	int adjmtr[100][100];
	InitializeIntegerMatrix(n, n, adjmtr);
	ListToMatrix(n, adjmtr);
	PrintIntegerMatrix(n, n, adjmtr);
	return 0;
}

C++: #include<iostream>
using namespace std;
#define  NIL 0
#define N 100

int main() {
  int n, u, k, v;
  int V[N][N];

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      V[i][j] = NIL;
    }
  }

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

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

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i];
    int x;
    cin >> x;
    k[u[i]-1]+=x;

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<4; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=3)
        cout << " ";
      }
      cout << endl;
    }
  }

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;
}