Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	g := make([][]int, N)
	for i, _ := range g {
		g[i] = make([]int, N)
	}
	for i := 0; i < N; i++ {
		u, k := sc.nextInt(), sc.nextInt()
		for j := 0; j < k; j++ {
			g[u-1][sc.nextInt()-1] = 1
		}
	}

	for _, r := range g {
		for i, num := range r {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, num)
		}
		fmt.Fprintln(wtr)
	}
	wtr.Flush()
}

C++: #include <iostream>
#include "string.h"
using namespace std;
int m[107][107];
int main(int argc, char *argv[]) {
	int n,u,k,v;
	cin>>n;
	memset(m, 0, sizeof(m));
	for(int i=1;i<=n;i++)
	{
		cin>>u>>k;
		for(int j=1;j<=k;j++)
		{
			cin>>v;
			m[u][v]=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 <iostream>
#include <string>
#include <vector>


using namespace std;


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


  vector< vector<int> > a;
  for(int i=0;i<n;i++){
    int u;
    int k;
    cin >> u >> k;
    vector<int> tmpa;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      tmpa.push_back(tmp);
    }

    a.push_back(tmpa);
  }

  
  
  int a2[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a2[i][j]=0;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<(int)a[i].size();j++){
      a2[i][a[i][j]-1] = 1;
    }
  }

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

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

using namespace std;

int main(void)
{
    int n, u, k, v;
    cin >> n;
    vector<vector<int>> vec(n, vector<int>(n));
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            vec[u-1][v-1] = 1;
        }
    }
    
    for (auto& i : vec) {
        int cnt = 0;
        for (auto& j : i) {
            cout << j;
            cnt++;
            if (cnt != n) cout << " ";
        }
        cout << endl;
    }
}

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

int main(){
    int M[N][N];//0 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--;//转换为零起点
            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 <cstdio>
using namespace std;
#define MAX_N (105)
bool G[MAX_N][MAX_N];
int main()
{
    int n;
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	int u, k;
	scanf("%d %d", &u, &k);
	for ( int j = 0; j < k; j++ ) {
	    int v;
	    scanf("%d", &v);
	    G[u-1][v-1] = true;
	}
    }

    for ( int i = 0; i < n; i++ ) {
	for ( int j = 0; j < n; j++ ) {
	    printf("%d%c", (int)G[i][j], (j == n - 1) ? '\n' : ' ');
	}
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int M[101][101];

int main(){
  int n,u,k,v;
  cin>>n;

  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;

int main(int argc, char** argv)
{
	// Input
	int adj_m[100][100] = { 0 };
	int n;
	cin >> n;
	int u,v,k;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			adj_m[u - 1][v - 1] = 1;
		}
	}

	// Output
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << " " << adj_m[i][j];
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,u,d;
    cin>>n;
    vector<vector<int> > Adj(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            Adj[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>k>>u;
        for(int j=0;j<u;j++){
            cin>>d;
            Adj[k-1][d-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<Adj[i][j]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
}

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] >> k[i];

    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<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }

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

int main(){
	int n, u, k, v;
	int Graph[100][100] = {};
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> u >> k; //u = ??????????????? k = u?????????????¬???°
		u--;
		for(int j = 0 ; j < k ; j++){
			cin >> v; //v = ??£??\?????????????????????
			v--;
			Graph[u][v] = 1;
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if(j != 0){
				cout << " ";
				}
			cout << Graph[i][j];
			}
		cout << endl;
		}
	
	return 0;
}

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

int a[100][100];
int N,u,k,col;
int main() {
	cin >> N;
	for(int i=0; i<N; ++i) {
		cin >> u >> k;
		for(int l=0; l<k; ++l) {
			cin >> col;
			a[u-1][col-1] = 1;
		}
		cout << a[i][0];
		for(int l=1; l<N; ++l) {
			cout << " " << a[i][l];
		}
		cout << endl;
	}
}

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

int main(){
    int n, u, k, v;
    cin >> n;
    bool a[n + 1][n + 1] = {0};
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> 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;
    }
    return 0;
}