jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

import "fmt"

func main() {
	var n, s string
	fmt.Scan(&n)
	s = ""
	for _, c := range n {
		switch string(c) {
		case "9":
			s += "1"
		case "1":
			s += "9"
		}
	}
	fmt.Println(s)
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(1110 - n)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := Scanner()
	for _, r := range n {
		if string(r) == "1" {
			fmt.Print(9)
		} else if string(r) == "9" {
			fmt.Print(1)
		} else {
			fmt.Print(string(r))
		}
	}
	fmt.Println("")
}
//  [go]
package main

import "fmt"

func main() {
	// Code for A - AtCoder Beginner Contest 999
	var n string
	fmt.Scanf("%s", &n)

	for i := 0; i < 3; i++ {
		if n[i] == '1' {
			fmt.Printf("9")
		} else {
			fmt.Printf("1")
		}
	}
	fmt.Printf("\n")
}
//  [ruby]
n=gets.chomp;puts n.gsub(/1|9/, "1" => "9", "9" => "1")
//  [ruby]
ans = ''
gets.chomp.chars.each do |c|
  if c == '1'
    ans << '9'
  elsif c == '9'
    ans << '1'
  else
    ans << c
  end
end
puts ans
//  [ruby]
puts gets.chomp.tr('19', '91')
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

test = N.to_s.split('').map do |n|
  if n == '9'
    '1'
  else
    '9'
  end
end

puts test.join
//  [ruby]
n = gets.chomp
3.times do |i|
  if n[i] == "1"
    n[i] = "9"
  else
    n[i] = "1"
  end
end
puts n
//  [ruby]
n = gets.chomp.split('').map(&:to_i)
i = 0
while i < n.size
  if n[i] == 1
    n[i] = 9
  else
    n[i] = 1
  end
  i += 1
end
puts n.join
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let a = n / 100;
    let b = (n / 10) % 10;
    let c = n % 10;
    // println!("{} {} {}", a, b, c);

    let mut ans = 0;

    if a == 9 {
        ans += 100
    } else {
        ans += 900
    }

    if b == 9 {
        ans += 10
    } else {
        ans += 90
    }
    if c == 9 {
        ans += 1
    } else {
        ans += 9
    }
    println!("{}", ans);
}
//  [rust]
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let mut n = read_as_vec::<u32>()[0];
    let mut ans = 0;

    let mut base = 1;
    for i in 0..3{
        let tmp = n%10;
        if tmp == 1 || tmp == 9{
            ans += (10-tmp)*base;
        }else{
            ans += tmp*base;
        }
        base *= 10;
        n /= 10;
    }
    println!("{}", ans);
}
//  [rust]
use std::io::Read;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();


    for c in buf.chars() {
        if c == '1' {
            print!("{}", '9')
        }
        if c == '9' {
            print!("{}", '1')
        }
    }
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    println!("{}",
             if a=="111" {"999" }
             else if a=="119" {"991" }
             else if a=="191" {"919" }
             else if a=="199" {"911" }
             else if a=="911" {"199" }
             else if a=="919" {"191" }
             else if a=="991" {"119" }
             else {"111" }
    )
}
//  [rust]
use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: Chars
    };

    for &i in n.iter() {
        if i == '1' {
            print!("9")
        } else {
            print!("1")
        }
    }
}
//  [rust]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    mut n: Chars,
    }
    for i in 0..3 {
        let d = match n[i] {
            '1' => '9',
            _ => '1'
        };
        print!("{}", d)
    }
}
//  [swift]
var ans = ""
readLine()!.characters.map{String($0)}.forEach{ans += ($0 == "1" ? "9" : "1")}
print(ans)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};
const main = ()=>{
  let s= sin();
  out((s[0]=='1'?'9':'1')+(s[1]=='1'?'9':'1')+(s[2]=='1'?'9':'1'));
}
main();
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.split('\n')[0]

const res = s.split('').map(e => {
  if(e === '1') return '9'
  if(e === '9') return '1'
  return e
}).join('')

console.log(res)
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc111 {

    class Program {
        /**
         * ins
         *  119
         * out
         *  991
         */
        main(inp: string): void {

            const x: string[] = inp.split('').map(n => {
                if (n === '1') {
                    return '9';
                } else {
                    return '1';
                }
            });
            console.log(x.join(''));
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const n = input[0][0];

  return Number(
    n
      .split("")
      .map((char) => (char === "1" ? "9" : "1"))
      .join("")
  );
};

console.log(main(read()));
//  [typescript]
export default solve;

// =================================================
// ABC110A
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { nums } = parseLines(lines);

  return nums.map(n => (n === 1 ? 9 : 1)).join('');
}

// helpers
function parseLines(lines: string[]) {
  const nums = lines[0].split('').map(s => +s);
  const obj = { nums };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}
//  [typescript]
const main = (): void => {
  const s = getParams();
  console.log(solve(s));
};

const getParams = (): string =>
  getStdin();

const getStdin = (): string =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = (s: string): string =>
  s.split('').map(replace).join('');

const replace = (c: string): string =>
  c === '1' ? '9' : '1';

main();
//  [python]
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)

#入力
s = input()
#解答
state = 0
if s[2] == s[3]:
    state = 1
else:
    print("No")
    sys.exit()
if s[4] == s[5]:
    state = 1
else:
    state = 0
    print("No")
    sys.exit()
if state == 1:
    print("Yes")
#出力
//  [python]
import sys
import numpy as np

from collections import deque 
from functools import reduce

# input = sys.stdin.readline

s = input()

if (s[2] == s[3]) and (s[4] == s[5]):
    print("Yes")
else:
    print("No")
//  [python]
# -*- coding: utf-8 -*-
import numpy as np

s = str(input())

if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
//  [java]

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	/**
	 * for (int i = 0; i < N; i++) {}
	 * System.out.println();
	 * HashMap<Integer, Integer> hm = new HashMap<>();
	 * int[] s = new int[M];
	 * ArrayDeque<Integer> deq = new ArrayDeque<>();
	 *
	 * 文字列のSort
	 * String sorted = S.chars()
						.sorted()
						.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
						.toString();
	 * for (char i = 'a'; i <= 'z'; i++) {}
	 */
	public void run() {
		FastScannerMainA sc = new FastScannerMainA(System.in);

		try {
			String S = sc.nextLine().trim();
			//int[] a = new int[N];
			//long l = sc.nextLong();
			//ArrayList<Integer> arr = new ArrayList<Integer>();
			//for (int i = 0; i < N; i++) {}
			//for (char i = 'a'; i <= 'z'; i++) {}

			boolean s34 = false;
			boolean s56 = false;

			//System.out.println(S.substring(2, 3));
			//System.out.println(S.substring(3, 4));
			if (S.substring(2, 3).equals(S.substring(3, 4))) {
				s34 = true;
			}

			if (S.substring(4, 5).equals(S.substring(5, 6))) {
				s56 = true;
			}

			if (s34 && s56) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMainA {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMainA(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}
//  [java]

import java.util.*;
import java.lang.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		String str = s.nextLine();

		if(str.charAt(2)==str.charAt(3) && str.charAt(4)==str.charAt(5)){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}

 }
//  [cpp]
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		int idx = -1;
		for(int i = 0; i < 5; ++i){
			if(s[i] == s[i + 1]){
				idx = i;
				break;
			}
		}
		if(idx >= 0){
			c += (idx + 1) * 0.1 * CLOCKS_PER_SEC;
			while(clock() < c);
		}
		cout << "No\n";
	}
}
//  [cpp]
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	c += (s[0] - 'a' + 1) * 0.01 * CLOCKS_PER_SEC;
	while(clock() < c);
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}
//  [cpp]
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	c += (s[4] - 'a' + 1) * 0.01 * CLOCKS_PER_SEC;
	while(clock() < c);
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}
//  [c]
#include <stdio.h>

int main(){
  char S[6];
  
  scanf("%s",S);
  
  if(S[2] == S[3] && S[4] == S[5]) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
char name[7];
  int i;
  	scanf("%s", name);
  if(name[2]==name[3] && name[4]==name[5]){
  printf("Yes\n");
  }
  else
    printf("No\n");
  return 0;
}
//  [c]
#include <stdio.h>

int main() {
  char S[7];
  int result = 0;
  scanf("%s",S);
  for(int i=2;i<6;i+=2) {
    if(S[i]==S[i+1]) {
      result++;
    }
  }
  if(result==2) {
    printf("Yes");
  }else {
    printf("No");
  }
  return 0;
}
//  [javascript]
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = parseLine(input)[0];
	console.log((input[2]==input[3] && input[4]==input[5])?'Yes':'No');
}
// Don't edit this line!
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
	if(input.charAt(2) == input.charAt(3) && input.charAt(4) == input.charAt(5)){
		console.log("Yes");
	}else{
		console.log("No");
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'
function main(inp) {
  let ans = "No";
  if(inp[2] === inp[3] && inp[4] === inp[5]){
  	ans = "Yes"
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	S := scanner.Text()

	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [ruby]
# Wrote in Mar 28, 2020 21:00 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

s = gets.chomp
if s[2]==s[3]&&s[4]==s[5]
  yes
else
  no
end
//  [ruby]
s = gets
if s[2]==s[3] && s[4]==s[5]
  puts :Yes
else
  puts :No
end
//  [ruby]
S=gets
puts S[2]==S[3]&&S[4]==S[5] ? :Yes : :No
//  [rust]
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s = line.trim();
    if (s.chars().nth(2) == s.chars().nth(3)) & (s.chars().nth(4) == s.chars().nth(5)) {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
    }

    if s[2] == s [3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [swift]
import Foundation

let chr = readLine()!.characters.map{ String($0) }
if (chr[2] == chr[3] && chr[4] == chr[5]){
  print("Yes")
}else{
  print("No")
}
//  [swift]
import Foundation

let S = readLine()!

var charList = [Character]()

for c in S.characters{
    charList.append(c)
}

if charList[2] == charList[3] && charList[4]  == charList[5] {
    print("Yes")
} else {
    print("No")
}
//  [typescript]
"use strict";

const main = arg => {
  const input = arg.trim().split("\n")[0];
  if (input.substring(2,3) === input.substring(3,4) && input.substring(4,5) === input.substring(5,6)) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
process.stdin.resume();
process.stdin.setEncoding("utf8");

// 標準入力取込
let gInput = "";
process.stdin.on("data", (chunk) => gInput += chunk);
process.stdin.on("end", () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {

    // 整数の数
    const str: string[] = Array.from(inputs[0]);

    if (str[2] === str[3] && str[4] === str[5]) {

        return console.log('Yes');
    }

    return console.log('No');
}
//  [python]
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    next_n = [0] * n
    used[s] = False
    edgelist = []
    for e in edge[s]:
        e.append(s)
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        next_n[v] = minedge[2]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1],v])
    return d, next_n

################################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    a,b = map(int,input().split())
    edge[b-1].append([1,a-1])
    edge[a-1].append([1,b-1]) 
res_list, next_list = dijkstra_heap(0)
if float('inf') in res_list:
  print("No")
else:
  print("Yes")
  for res in next_list[1:]:
    print(res+1)
//  [python]
import heapq
n, M = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a] += [[b, 1]]
  graph[b] += [[a, 1]]

def dijkstra(s):
  dist = [float('inf')]*n
  dist[s] = 0
  num = [0]*n
  num[s] = 1
  q = [[0, s]]
  pre = [0]*n
  heapq.heapify(q)
  while q:
    c, u = heapq.heappop(q)
    if dist[u] < c:
      continue
    for v, weight in graph[u]:
      if dist[v] > dist[u] + weight:
        dist[v] = dist[u] + weight
        num[v] = num[u]
        heapq.heappush(q, [dist[v], v])
        pre[v] = u
      elif dist[v] == dist[u] + weight:
        num[v] += num[u]
  return dist, num, pre

dist, num, pre = dijkstra(0)
print('Yes')
for i in pre[1:]:
  print(i+1)
//  [python]
import networkx as nx
N, M = map(int, input().split())

G = nx.Graph()

G.add_edges_from(tuple(map(int, input().split())) for _ in range(M))

dist = nx.shortest_path_length(G, target=1)
print('Yes')
for i in range(2, N+1):
  print(min((dist[j], j) for j in nx.all_neighbors(G, i))[1])
//  [java]
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		Set<Integer> endcheck = new HashSet<>();
		endcheck.add(1);
		Set<Integer> start = new HashSet<>();
		start.add(1);

		do {
			Set<Integer> tmpst = new HashSet<>();

			Iterator<Integer> stit = start.iterator();
			while(stit.hasNext()) {
				int v1 = stit.next();

				int tdist = dist[v1] + 1;

				Iterator<Integer> adjit = adj[v1].iterator();
				while(adjit.hasNext()) {
					int v2 = adjit.next();
					if(!endcheck.contains(v2)) {
						tmpst.add(v2);
						endcheck.add(v2);

						if(dist[v2] < 1 || dist[v2] > tdist) {
							dist[v2] = tdist;
							ans[v2] = v1;
						}
					}

				}
			}

			start = tmpst;

		}while(endcheck.size() < n);

		System.out.println("Yes");
		for(int i = 2; i < n+1; i++) {
			System.out.println(ans[i]);
		}


	}

}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            final int ROOM = s.nextInt(), PATH = s.nextInt();
            var paths = new HashMap<Integer, Set<Integer>>();
            for (int i = 0; i < PATH; i++) {
                int a = s.nextInt(), b = s.nextInt();
                paths.computeIfAbsent(a, k -> new HashSet<>()).add(b);
                paths.computeIfAbsent(b, k -> new HashSet<>()).add(a);
            }
            var sign = new HashMap<Integer, Integer>();
            sign.put(1, 0);
            var queue = new ArrayDeque<Integer>();
            queue.add(1);
            while (!queue.isEmpty()) {
                Integer i = queue.pollFirst();
                var to = paths.get(i);
                for (Integer j : to) {
                    if (sign.containsKey(j)) {
                        continue;
                    }
                    sign.put(j, i);
                    queue.add(j);
                }
            }
            System.out.println("Yes");
            for (int i = 2; i <= ROOM; i++) {
                System.out.println(sign.get(i));
            }
        }
    }
}
//  [cpp]
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    int a[m],b[m];

    vector<vector<int>> G(n);

    for(int i=0;i<m;i++){
        cin >> a[i];
        cin >> b[i];
        G[a[i]-1].push_back(b[i]-1);
        G[b[i]-1].push_back(a[i]-1);
    }

    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    vector<vector<int>> C(n);

    C[0].push_back(0);

    for(int i=1;i<n;i++){
        C[dist[i]].push_back(i);
    }

    int c[n]={};
    int q=0;

    for(int i=1;i<n;i++){
        for(int j=0;j<C[i].size();j++){
            if(i==1)c[C[i][j]]=1;
            else{
                for(int k=0;k<G[C[i][j]].size();k++){
                    for(int l=0;l<C[i-1].size();l++){
                        if(C[i-1][l]==G[C[i][j]][k]){
                            c[C[i][j]]=C[i-1][l]+1;
                            break;    
                        }
                    }
                }
            }
        }
    }

    cout << "Yes" << endl;

    for(int i=1;i<n;i++){
        cout << c[i] << endl;
    }


}
//  [cpp]
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)

struct cmp
{
    template <typename T, typename U>
    bool operator()(T const &left, U const &right)
    {
        if (left.second > right.second)
            return true;
        return false;
    }
};

int edgeTo[100000 + 5];
int distTo[100000 + 5];
set<pair<int, int>> pq;
void relax(int from, int to, int weight)
{
    if (distTo[to] > distTo[from] + weight)
    {
        pair<int, int> backup = {to, distTo[to]};
        distTo[to] = distTo[from] + weight;
        edgeTo[to] = from;
        if (pq.find(backup) != pq.end())
        {
            pq.erase(backup);
            pq.insert({to, distTo[to]});
        }
        else
        {
            pq.insert({to, distTo[to]});
        }
    }
}

void dijsktra(vector<vector<pair<int, int>>> g, int s)
{
    int n = g.size();
    for (int i = 0; i < n + 1; i++)
    {
        distTo[i] = 2147483647;
    }

    distTo[s] = 0;
    pq.insert({s, 0});
    while (!pq.empty())
    {
        auto it = pq.end();
        it--;
        pair<int, int> top = *it;
        pq.erase(*it);
        for (pair<int, int> e : g[top.first])
        {
            relax(top.first, e.first, e.second);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> graph(n + 1);
    rep(i, 1, m + 1)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back({b, 1});
        graph[b].push_back({a, 1});
    }
    dijsktra(graph, 1);

    cout << "Yes" << endl;
    rep(i, 2, n + 1)
    {
        cout << edgeTo[i] << endl;
    }
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long step;
	long connected;
} S_VERTICE;

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long **tree;
  tree = (long **)malloc(sizeof (long*) * (n+1));
  for (long i = 0; i < n+1; i++) {
    tree[i] = (long *)malloc(sizeof (long) * (m+1));
    tree[i][0] = 0;
  }
  for (long i = 1; i <= n; i++) {
    tree[0][i] = 0;
  }
  long a,b;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a][0]++;
    tree[a][tree[a][0]] = b;
    tree[b][0]++;
    tree[b][tree[b][0]] = a;
  }
  S_VERTICE vertices[n+1];
  for (long i = 1; i <= n; i++) {
		vertices[i].step = -1;
    vertices[i].connected = -1;
  }
	vertices[1].step = 1;
	vertices[1].connected = 0;

	long visited[n];
	visited[0] = 1;
	long head = 0;
	long tail = 0;
	long tmp_tail;
  long cur;
  while (1) {
		tmp_tail = tail;
    for (long i = head; i <= tail; i++) {
			cur = visited[i];
    	for (long j = 1; j <= tree[cur][0]; j++) {
				if (vertices[tree[cur][j]].connected != -1) {
					continue;
				}
    		vertices[tree[cur][j]].step = vertices[cur].step+1;
				vertices[tree[cur][j]].connected = cur;
				tmp_tail++;
				visited[tmp_tail] = tree[cur][j];
    	}
    }
		head = tail+1;
		tail = tmp_tail;
		if (tail == n-1) {
			break;
		}
  }
	free(tree);

	printf("Yes\n");

  for (long i = 2; i <= n; i++) {
    printf("%ld \n", vertices[i].connected);
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int **graph;
  graph = (int**)malloc(sizeof(int*)*(n+22));
  for(int i=0; i<n+22; i++)
    graph[i] = malloc(sizeof(int)*(m+22));
  while(m--){
    int a, b;  scanf("%d %d", &a, &b);
    graph[a][++graph[a][0]] = b;
    graph[b][++graph[b][0]] = a;
  }

  int ans[100005] = {0}, anscount = 0;  ans[1] = 1;
  int queue[100000], front = 0, rear = 0, qsize = 100000;
  queue[rear++] = 1;
  while(front != rear){
    int now = queue[front];  front = (front+1)%qsize;
    for(int i=1; i<=graph[now][0]; i++)
      if(!ans[graph[now][i]]){
	ans[graph[now][i]] = now;
	queue[rear] = graph[now][i];
	rear = (rear+1)%qsize;
	anscount++;
      }
  }

  if(anscount != n-1){
    printf("No\n");
  }else{
    printf("Yes\n");
    for(int i=2; i<=n; i++)
      printf("%d\n", ans[i]);
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define min(a, b) ((a) < (b))?(a):(b)

#define INF 1001001001

struct list {
	int item;
	struct list * next;
} **to;

void initializeList(int n)
{
	int i;
	for (i = 0; i < n; i++) {
		to[i] = NULL;
	}
}

struct list *insertList(struct list *p, int x)
{

	struct list *q;
	q = (struct list *)malloc(sizeof(struct list));
	q->item = x;
	q->next = p;
	
	return q;
}

struct queue {
	int item;
	struct queue *next;
} *head, *tail;

void initializeQueue(void)
{
	head = tail = (struct queue *)malloc(sizeof(struct queue));
}

void addQueue(int x)
{
	tail->item = x;
	tail->next = (struct queue *)malloc(sizeof(struct queue));
	tail = tail->next;
}

int removeQueue(void)
{
	int x;
	struct queue *p;
	p = head;
	head = p->next;
	x = p->item;
	free(p);
	return x;
}

int main()
{
	int ret, i, n, m;
	int a, b;
	int *prev;
	int *dist;
	int v, u;
	struct list *pu;
	int ans;
	
	ret = scanf("%d %d", &n, &m);

	to = (struct list **)malloc(sizeof(struct list*)*n);
	for (i = 0; i < n; i++)
		to[i] = (struct list *)malloc(sizeof(struct list)*n);
	initializeList(n);
	
	prev = (int *) malloc(sizeof(int)*n);
	for (i = 0; i < n; i++)
		prev[i] = -1;
	dist = (int *) malloc(sizeof(int)*n);
	for (i = 0; i < n; i++)
		dist[i] = INF;
	
	for (i = 0; i < m; i++) {
		ret = scanf(" %d %d", &a, &b);
		--a;
		--b;
		to[a] = insertList(to[a], b);
		to[b] = insertList(to[b], a);
	}

	initializeQueue();
	dist[0] = 0;
	addQueue(0);
	do {
		v = removeQueue();
		for (pu = to[v]; pu != NULL; pu = pu->next) {
			u = pu->item;
			if (dist[u] !=INF) continue;
			dist[u] = dist[v]+1;
			prev[u] = v;
			addQueue(u);
		}
	} while(head != tail);
	
	printf("Yes\n");
	for (i = 0; i < n; i++) {
		if (i == 0) continue;
		ans = prev[i];
		++ans;
		printf("%d\n", ans);
	}
	
	fflush(stdout);
	free(prev);
	free(dist);
	for (i=0;i<n;i++)
		free(to[i]);
	free(to);
	return EXIT_SUCCESS;
}
//  [javascript]
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const n = parseInt(input[0].split(" ")[0]);
    const m = parseInt(input[0].split(" ")[1]);
    let abs = Array(n+1).fill(0).map(_ => [])
    for (let i = 1; i < input.length; i++) {
        let [a, b] = input[i].split(" ").map(el => parseInt(el))
        abs[a].push(b)
        abs[b].push(a)
    }
    let dp = {}
    dp[1] = 1
    let q = [1]
    let seen = new Set()
    while (q.length > 0) {
        let id = q.shift()
        for (let key of abs[id]) {
            if (!seen.has(key)) {
                dp[key] = id
                q.push(key)
                seen.add(key)
            }
        }
    }
    if (n !== Object.keys(dp).length) {
        console.log('No')
        return
    }
    console.log('Yes')
    for (let i = 2; i <= n; i++) {
        console.log(dp[i])
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const main = (input) => {
  const [a, ...qs] = input.trim().split('\n')
  const [N,] = a.split(' ').map(Number)
  const q = qs.map(v => v.split(' ').map(Number))

  const cave = new Array(N+1).fill().map(() => [])

  for (let [a, b] of q) {
    cave[a].push(b)
    cave[b].push(a)
  }

  const visited = { '1': true }
  const ans = ['Yes', ...new Array(N).fill(0)]
  let queue = [1]

  while (queue.length) {
    const nextQ = []
    while (queue.length) {
      const v = queue.shift()
      const links = cave[v]

      for (let l of links) {
        if (visited[l]) continue
        nextQ.push(l)
        ans[l] = v
        visited[l] = true
      }
    }

    queue = nextQ
  }

  for (let i=0; i<=N; i++) {
    if (i===1) continue
    console.log(ans[i])
  }
  return null
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
const main = (input) => {
  const args = input.split('\n')
  const nm = args[0].split(' ').map(v => Number(v))
  const n = nm[0]
  const m = nm[1]
  const lines = args.slice(1, args.length).map(line => line.split(' ').map(v => Number(v)))
  const room = Array(n + 1).fill(0).map(() => [])
  for (let i = 0; i < m; i++) {
    const [a, b] = lines[i]
    room[a].push(b)
    room[b].push(a)
  }
  let prev = Array(n).fill(-1)
  prev[0] = 0
  const queue = []
  queue.push(1)
  while (queue.length > 0) {
    const p = queue.shift()
    room[p].forEach(n => {
      if (prev[n - 1] !== -1) {
        return
      }
      prev[n - 1] = p
      queue.push(n)
    })
  }
  console.log('Yes')
  for (let i = 1; i < n; i++) {
    console.log(prev[i])
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [go]
// 1からスタンプを押していくBFS
// golangでpriority queueもってないから愚直FIFOで間に合うかどうかは正直わからん
package main

import "fmt"

type Pos struct {
	cur, pre int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	T := make([][]int, N+1)
	for i := 1; i <= N; i++ {
		T[i] = []int{}
	}
	for i := 0; i < M; i++ {
		var A, B int
		fmt.Scan(&A, &B)
		T[A] = append(T[A], B)
		T[B] = append(T[B], A)
	}
	passed := make([]int, N+1)
	passed[1] = -1
	queue := []Pos{Pos{cur: 1, pre: 0}}
	for len(queue) > 0 {
		nex_queue := []Pos{}
		for i := 0; i < len(queue); i++ {
			now := queue[i]
			for _, nex := range T[now.cur] {
				if passed[nex] == 0 {
					nexPos := Pos{cur: nex, pre: now.cur}
					passed[nex] = now.cur
					nex_queue = append(nex_queue, nexPos)
				}
			}
		}
		queue = nex_queue
	}
	fmt.Println("Yes")
	for _, ans := range passed[2:] {
		fmt.Println(ans)
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	var A, B int
	E := make([][]int, N)
	for i := 0; i < N; i++ {
		E[i] = make([]int, 0)
	}
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %d", &A, &B)
		E[A-1] = append(E[A-1], B)
		E[B-1] = append(E[B-1], A)
	}

	prevRooms := make([]int, N)
	for i := 0; i < N; i++ {
		prevRooms[i] = -1
	}

	nowRooms := []int{1}
	for {
		nextRooms := []int{}
		for _, nowRoom := range nowRooms {
			for _, nextRoom := range E[nowRoom-1] {
				if prevRooms[nextRoom-1] > 0 {
					continue
				}
				prevRooms[nextRoom-1] = nowRoom
				nextRooms = append(nextRooms, nextRoom)
			}
		}
		if len(nextRooms) == 0 {
			break
		}
		nowRooms = nextRooms
	}
	if len(prevRooms) > 0 {
		fmt.Println("Yes")
		for index, prevRoom := range prevRooms {
			if index == 0 {
				continue
			}
			fmt.Println(prevRoom)
		}
	}
}
//  [go]
package main

import "fmt"

var INF int = 1001001001

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	var A, B int
	E := make([][]int, N)
	for i := 0; i < N; i++ {
		E[i] = make([]int, 0)
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&A, &B)
		A = A - 1
		B = B - 1
		E[A] = append(E[A], B)
		E[B] = append(E[B], A)
	}
	dist := make([]int, N)
	pre := make([]int, N)
	var q []int
	for i := 0; i < N; i++ {
		dist[i] = INF
		pre[i] = -1
	}
	dist[0] = 0
	q = append(q, 0)
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for i := 0; i < len(E[v]); i++ {
			u := E[v][i]
			if dist[u] != INF {
				continue
			}
			dist[u] = dist[v] + 1
			pre[u] = v
			q = append(q, u)
		}
	}
	fmt.Println("Yes")
	for i := 1; i < N; i++ {
		ans := pre[i]
		ans++
		fmt.Println(ans)
	}
}
//  [ruby]
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]

access = []
for i in 1..N do
  access[i-1] = []
end
for j in 1..M do
  access[lines[j][0]-1].push(lines[j][1])
  access[lines[j][1]-1].push(lines[j][0])
end

label = []
unlabeled = []
for i in 1..N do
  unlabeled.push(i)
end

label[0] = 0
for i in 1..N do
  label[i-1] = "none"
end

next_target = [1]
while unlabeled != [] do
  last_target = next_target
  next_target = []
  last_target.each do |go_to|
    access[go_to-1].each do |go_from|
      if label[go_from-1] == "none" then
        label[go_from-1] = go_to
        next_target.push(go_from)
        unlabeled.delete_at(0)
      end
    end
  end
end

puts "Yes"
for i in 2..N do
  puts label[i-1]
end
//  [ruby]
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]

access = []
for i in 1..N do
  access[i-1] = []
end
for j in 1..M do
  access[lines[j][0]-1].push(lines[j][1])
  access[lines[j][1]-1].push(lines[j][0])
end

label = []
finished = []

for i in 1..N do
  label[i-1] = []
  finished[i-1] = false
end

targets = [1]
while targets.length != 0  do
  current_target = targets[0]
  access[current_target-1].each do |go_from|
    if finished[go_from-1] == false then
      label[go_from-1] = current_target
      targets.push(go_from)
      finished[go_from-1] = true
    end
  end
  targets.delete_at(0)
end

puts "Yes"
for i in 2..N do
  puts label[i-1]
end
//  [ruby]
n,m  = gets.chomp.split
n = n.to_i
m = m.to_i
arr = Array.new(n).map{Array.new()}
nama = Array.new
while line = $stdin.gets
nama << line.chomp.split(" ").map(&:to_i)
arr[nama[-1][0]-1].push(nama[-1][1]-1)
arr[nama[-1][1]-1].push(nama[-1][0]-1)
end

dist = Array.new(n)
dist.fill(-1)
dist[0] = 0

que = []
que.push(0)

until que.empty? do
    arr[que[0]].each{|item|
        if dist[item] == -1
            dist[item] = dist[que[0]] + 1
            que.push(item)
        end
    }
    que.delete_at(0)
end
ans = Array.new(n)

nama.each{|item|
    if dist[item[0]-1] == dist[item[1]-1]
        next
    elsif dist[item[0]-1] > dist[item[1]-1]
        ans[item[0]-1] = item[1]
    else
        ans[item[1]-1] = item[0]
    end
}

puts "Yes",ans[1..-1]
//  [rust]
use proconio::input;

// https://atcoder.jp/contests/abc168

fn main() {
    input! {
        nm: (usize, usize),
        ab: [(usize, usize); nm.1],
    }
    let mut cave = vec![vec![]; nm.0+1];
    for p in ab {
        cave[p.0].push(p.1);
        cave[p.1].push(p.0);
    }
    for i in 1..cave.len() {
        cave[i].sort();
    }

    let mut check = vec![0; nm.0+1];
    check[1] = 1;
    let mut que = vec![];
    que.push(1);

    while que.len() > 0 {
        let v = que.remove(0);

        for &i in &cave[v] {
            if check[i] != 0 {
                continue;
            }
            check[i] = v;
            que.push(i);
        }
    }
    
    println!("Yes");
    for i in 2..check.len() {
        println!("{}", check[i]);
    }
}
//  [swift]
func readIntTuple() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

struct LinkedList<T> {
    
    var first: Node?
    var last: Node?
    
    var isEmpty: Bool {
        return first == nil
    }
    
    mutating func append(_ e: T) -> Void {
        let node = Node(e)
        if first == nil {
            first = node
        }
        if let lastElement = last {
            lastElement.next = node;
            node.prev = lastElement;
        }
        last = node
    }
    
    mutating func delete(_ node: Node) {
        if let prev = node.prev {
            prev.next = node.next
        } else {
            first = node.next
        }
        if let next = node.next {
            next.prev = node.prev
        } else {
            last = node.prev
        }
    }
    
    mutating func removeFirst() -> T? {
        guard let firstNode = first else {
            return nil
        }
        delete(firstNode)
        return firstNode.value
    }
    
    class Node {
        var value: T
        var prev: Node?
        var next: Node?
        
        init(_ value: T) {
            self.value = value
        }
    }
}

let (N, M) = readIntTuple()
var adjacent: [[Int]] = Array(repeating: [], count: N + 1)
(1...M).forEach({ _ in
    let (A, B) = readIntTuple()
    adjacent[A].append(B)
    adjacent[B].append(A)
})

var parent = Array(repeating: -1, count: N + 1)
var list = LinkedList<Int>()
list.append(1)
while !list.isEmpty {
    let room = list.removeFirst()!
    adjacent[room].forEach({
        if parent[$0] < 0 {
            parent[$0] = room
            list.append($0)
        }
    })
}

print("Yes")
(2...N).forEach({print(parent[$0])})
//  [python]
# coding: utf-8
# Your code here!
from collections import deque
s=deque(input())
Q=int(input())
count=0
query=[]
for i in range(Q):
    arr=input().split()
    query.append(arr)

for i in range(Q):
    if query[i][0]=="1":
        count+=1
    else:
        if count%2==0:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="1":
                s.append(query[i][2])
            else:
                s.appendleft(query[i][2])
if count%2==0:
    for i in range(len(s)):
        print(s[i],end="")
        
else:
    s.reverse()
    for i in range(len(s)):
        print(s[i],end="")
//  [python]
import math

S = input().strip()
Q = int(input().strip())
order = 1
tmp = 'T'

for i in range(Q):
  q = input().strip().split()
  #print(q)
  if q[0] == '1':
    # 反転
    # S = S[::-1]
    order *= -1
  else:
    F = q[1]
    if F == '1':
      if order == 1:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp
      else:
        # 末尾にCを追加
        # S = S + q[2]
        tmp = tmp + q[2]
    else:
      if order == 1:
        # 末尾にCを追加
        # S = S + q[2]        
        tmp = tmp + q[2]
      else:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp

S = tmp.replace('T', S)        
print(S[::order])
//  [python]
s = input()
q = int(input())
li=[list(map(str,input().split())) for _ in range(q)]

moji = "0"
frag = True

for i in range(q):
    que = li[i]
    if que[0] == "1":
        if frag:
            frag = False
        else:
            frag = True
    else:
        f = que[1]
        c = que[2]
        if frag:
            if f == "1":
                moji = c+moji
            else:
                moji = moji+c
        else:
            if f == "1":
                moji = moji+c
            else:
                moji = c+moji


if frag:
    print(moji.replace("0",s))
else:
    moji = moji[::-1]
    print(moji.replace("0",s[::-1]))
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int q = sc.nextInt();
		boolean reverseFlag = false;

		StringBuilder front = new StringBuilder();
		StringBuilder back = new StringBuilder();
		for(int i =0;i < q;i++) {
			int t = sc.nextInt();
			if(t ==1) {
				if(reverseFlag) {
					reverseFlag = false;
				}else {
					reverseFlag = true;
				}
			}else {
				int f = sc.nextInt();
				if(f == 1) {
					if(reverseFlag) {
						back.append(sc.next());
					}else {
						front.insert(0, sc.next());
					}
				}else {
					if(reverseFlag) {
						front.insert(0, sc.next());
					}else {
						back.append(sc.next());
					}
				}
			}
		}
		StringBuilder answer = new StringBuilder();
		answer.append(front);
		answer.append(s);
		answer.append(back);
		if(reverseFlag) {
			System.out.println(answer.reverse());

		}else {
			System.out.println(answer);
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		StringBuffer sb1 = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		boolean reverse = false;
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			int q = scan.nextInt();
			if (q == 1) {
				reverse = !reverse;
			} else {
				int f = scan.nextInt();
				String c = scan.next();
				if (f == 1) {
					if (!reverse) {
						sb1.insert(0, c);
					} else {
						sb2.append(c);
					}
				} else {
					if (!reverse) {
						sb2.append(c);
					} else {
						sb1.insert(0, c);
					}
				}
			}
		}

		StringBuffer sb = new StringBuffer();
		sb.append(sb1);
		sb.append(s);
		sb.append(sb2);
		if (reverse) {
			sb.reverse();
		}

		System.out.println(sb.toString());
		scan.close();
	}
}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        StringBuilder sbHead = new StringBuilder();
        StringBuilder sbTail = new StringBuilder();
        int q = in.nextInt();
        int asc = 1;
        for(int i=0; i<q; i++) {
            int t = in.nextInt();
            if(t==1) {
                asc *= -1;
                continue;
            }
            int f = in.nextInt();
            String c = in.next();
            if((asc>0&&f==1) || (asc<0&&f==2)) {
                sbHead.insert(0, c);
            }
            else {
                sbTail.append(c);
            }
        }
        if(asc>0) {
            System.out.println(sbHead.toString() + s + sbTail.toString());
        }
        else {
            StringBuilder sb = new StringBuilder(s);
            System.out.println(sbTail.reverse().toString() + sb.reverse().toString() + sbHead.reverse().toString());
        }
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    string T;
    int Q;
    cin >> S >> Q;
    int Quer;
    int F;
    char C;
    int judge = 0;

    for (int i = 0; i < Q; i++) {
        cin >> Quer;
        if (Quer == 1){
            judge++;
        }
        else {
            cin >> F >> C;
            if (F == 1){
                if (judge % 2 == 0){
                    T = T + C;
                }
                else {
                    S = S + C;
                }
            }
            else {
                if (judge % 2 == 0){
                    S = S + C;
                }
                else {
                    T = T + C;
                }
            }
        }
    }
    reverse(T.begin(), T.end());
    S = T + S;
    if (judge % 2 == 1){
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
}