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<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}Graph;

main(){
  int i,j,n;
  int a[100][100];
  Graph node[100];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&node[i].u);
    scanf("%d",&node[i].k);
    for(j=0;j<node[i].k;j++)scanf("%d",&node[i].v[j]);
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
    for(j=0;j<node[i].k;j++){
      a[i][node[i].v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j<n)printf(" ");
    }
    if(i<n)printf("\n");
  }

  return 0;
}

C++: #include <iostream>
#include <array>
#include <algorithm>

const int size = 1005;
using matrix = std::array<std::array<int, size>, size>;

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


  matrix a;
  std::for_each(a.begin(), a.end(), [](auto x){x.fill(0);});

  auto nn = n;
  while (nn != 0)
    {
      int i, k;
      std::cin >> i >> k;
      while (k != 0)
        {
          int j;
          std::cin >> j;
          a[i-1][j-1] = 1;
          --k;
        }
      --nn;
    }

  for (int i=0; i<n; ++i)
    {
      for (int j=0; j<n; ++j)
        {
          if (j) std::cout << ' ';
          std::cout << a[i][j];
        }
      std::cout << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

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

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          printf("0 ");
        }
        printf("0\n");
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            printf("0 ");
          }
          if (v[i][j] == n) {
            printf("1\n");
            break;
          }
          else {
            printf("1 ");
          }
        }
      }
    }
  }

  return 0;
}

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

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);

	int** gmtrx = new int*[n];
	for(int i=0; i<n; ++i){
		gmtrx[i] = new int[n];
		for(int j=0; j<n; ++j){
			gmtrx[i][j] = 0;
		}
	}

	for(int i=0; i<n; ++i){
		int v, num, a;
		scanf("%d %d",&v,&num);
		for(int j=0; j<num; ++j){
			scanf("%d",&a);
			gmtrx[v-1][a-1] = 1;
		}

	}

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

	for(int i=0; i<n; ++i){
		delete[] gmtrx[i];
	}
	delete[] gmtrx;

	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int list[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      list[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int u,k,to;
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>to;
      to--;
      for(int l=0;l<n;l++){
	if(l==to){
	  list[u][l]=1;
	}else{
	}
      }
    }
  }
  //print
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<list[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    int ans[n+1][n+1] = {0};
    for(int i = 0; i < n; i++){
        int index, k;
        cin >> index >> k;
        for(int j = 0; j < k; j++){
            int jndex;
            cin >> jndex;
            ans[index][jndex] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][n];
        cout << endl;
    }
    //cout << masu << endl;
    return 0;
}

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

namespace
{
void OutputRow(int Length, std::vector<int>::const_iterator Begin, std::vector<int>::const_iterator End)
{
	std::vector<int>::const_iterator It = Begin;
	for(int i = 1; i < Length; ++i){
		if(It == End || i < *It){
			std::cout << 0;
		}else{
			std::cout << 1;
			++It;
		}
		
		if(i < Length - 1){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
}
}//unnamed namespace
//================================================================

class TGraph
{
	std::vector<std::vector<int> > FNodes;
public:
	TGraph(int Count);
	
	void InputNodes(int Index, int BranchCount);
	void OutputAdjacencyMatrix()const;
};

TGraph::TGraph(int Count)
:FNodes(Count + 1)
{
}

void TGraph::InputNodes(int Index, int BranchCount)
{
	for(int i = 0; i < BranchCount; ++i){
		int Target;
		std::cin >> Target;
		FNodes[Index].push_back(Target);
	}
}

void TGraph::OutputAdjacencyMatrix()const
{
	for(unsigned int i = 1; i < FNodes.size(); ++i){
		OutputRow(FNodes.size(), FNodes[i].begin(), FNodes[i].end());
	}
}
//================================================================

int main()
{
	int Count;
	std::cin >> Count;
	TGraph Graph(Count);
	for(int i = 0; i < Count; ++i){
		int Index;
		std::cin >> Index;
		int BranchCount;
		std::cin >> BranchCount;
		Graph.InputNodes(Index, BranchCount);
	}
	Graph.OutputAdjacencyMatrix();
	return 0;
}