jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
func readInt() -> Int {
    return Int(readLine()!)!
}

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

// 普通にやるとTLE
// どの要素がどれだけあるかを持っておいて、差分更新をする
func mainD() {
    let N = readInt()
    var numbers = readInts()
    let Q = readInt()
    let pairs = (0..<Q).map { _ in readTwoInts() }

    var counts: [Int] = .init(repeating: 0, count: 1_000_00 + 1)

    for number in numbers {
        counts[number] += 1
    }

    var sum = 0
    for pair in pairs {
        let changed = counts[pair.a]
        counts[pair.b] += counts[pair.a]
        counts[pair.a] = 0

        if sum == 0 {
            sum = counts.enumerated().reduce(0) { $0 + ($1.offset * $1.element) }
            print(sum)
        } else {
            sum += (pair.b - pair.a) * changed
            print(sum)
        }
    }

//    var sums: [Int] = .init(repeating: 0, count: Q)
//    var index = 0
//    for pair in pairs {
//        numbers = numbers.map { number in
//            let newNumber = number == pair.a ? pair.b : number
//            sums[index] += newNumber
//            return newNumber
//        }
//
//        index += 1
//    }
//
//    for sum in sums {
//        print(sum)
//    }
}
mainD()
//  [swift]
_ = Int(readLine()!)!
let AN = readLine()!.split(separator: " ").compactMap { Int($0) }
let Q = Int(readLine()!)!
let BCQ: [(Int, Int)] = (1...Q).map { _ in
    let bc = readLine()!.split(separator: " ").compactMap { Int($0) }
    return (bc[0], bc[1])
}

var dict = [Int: Int]()
for an in AN {
    if dict[an] == nil {
        dict[an] = 1
    } else {
        dict[an]! += 1
    }
}

var sum = dict.reduce(0) { $0 + ($1.key * $1.value) }
for bc in BCQ {
    if dict[bc.0] != nil {
        let diff = (bc.1 - bc.0) * dict[bc.0]!
        sum += diff

        if dict[bc.1] != nil {
            dict[bc.1]! += dict[bc.0]!
        } else {
            dict[bc.1] = dict[bc.0]
        }
    }
    print(sum)
}
//  [swift]
import Foundation

var n = Int(readLine()!)!
var a = readLine()!.split(separator: " ").map{ Int($0)! }
var q = Int(readLine()!)!
var bc = (0..<q).map{ _ in readLine()!.split(separator: " ").map{ Int($0)! } }

for i in 0..<q {
    a = a.map{ $0 == bc[i][0] ? bc[i][1] : $0 }
    print(a.reduce(0, +))
}
//  [typescript]
{
  const run = (input: string) => {
    let split = input.trim().split("\n")
    const n = parseInt(split[0])
    const tmpList = split[1].split(" ").map(v => parseInt(v))

    let tmpSum = 0
    const list = {}
    for (let i = 0; i < n; i++) {
      const v = tmpList[i]
      list[v] = list[v] ? list[v] + 1 : 1
      tmpSum += v
    }

    const q = parseInt(split[2])

    const result = []
    const max = 3 + q
    for (let i = 3; i < max; i++) {
      const [from, to] = split[i].split(" ").map(v => parseInt(v))
      if (list[from]) {
        tmpSum = tmpSum - (from * list[from]) + (to * list[from])
        list[to] = list[from] + (list[to] || 0)
        list[from] = 0
      }

      result.push(tmpSum)
    }

    return result.join("\n")
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()
    const A = r.nn()
    const [Q] = r.nn()
    const bc = r.nnls()

    const counts = {}
    let sum = 0

    const res: string[] = []

    A.forEach((a) => {
      if (!counts[a]) counts[a] = 0
      sum += a
      counts[a]++
    })

    //

    bc.forEach(([b, c]) => {
      if (!counts[b]) {
        res.push(String(sum))
        return
      }
      const d = c - b

      sum += counts[b] * d

      res.push(String(sum))

      if (!counts[c]) counts[c] = 0
      counts[c] += counts[b]
      counts[b] = 0
    })

    return res.join('\n')
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [python]
L=list(map(int,input().split()))
K=sorted(L)
print(K[0]+K[1])
//  [python]
# A - ringring
a,b,c=list(map(int,input().split()))
print(sum([a,b,c])-max([a,b,c]))
//  [python]
l=list(map(int,input().split()))

print(sum(sorted(l)[:-1]))
//  [python]
a,b,c＝map(int,input().split())
print(a+b+c-max(a,b,c))
//  [python]
import sys
S = input()

for i in range(1, len(S)):
  s = S[:-i]
  l = len(s) // 2
  if s[:l] == s[l:]:
    print(len(s))
    sys.exit()
//  [python]
import sys
S = input()

for i in range(1, len(S)):
  s = S[:-i]
  l = len(s) // 2
  if s[:l] == s[l:]:
    print(len(s))
//  [java]
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		sc.fill(a);

		Arrays.sort(a);

		System.out.println(a[0] + a[1]);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");

    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);
    
    System.out.println((a <= c && b <= c) ? (a + b) : ((b <= a && c <= a) ? (b + c) : (a + c)));

  }

}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String str = br.readLine();
    
    StringTokenizer st = new StringTokenizer(str);
    
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    int c = Integer.parseInt(st.nextToken());
    
    int max = Integer.max(a, b);
    max = Integer.max(max, c);
    
    System.out.println(a+b+c-max);
  }

}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MAin {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a+b+c-(Math.max(a, Math.max(b, c))));

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		for (int i=0;i<3;i++) {
			A[i]= sc.nextInt();
		}
		System.out.println(A[0]+A[1]);
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		int length = S.length();

		while(true) {
			if ((S.length() -1) % 2 == 0) {
				String sub1 = S.substring(0, S.length() / 2);
//				System.out.println("sub1:" + sub1);
				String sub2 = S.substring(S.length() / 2, S.length() -1);
//				System.out.println("sub2:" + sub2);
				if (sub1.equals(sub2)) {
					System.out.println(S.length()-1);
					return;
				} else {
					S = S.substring(0, (S.length()-1));
				}
			} else {
				S = S.substring(0, (S.length()-1));
			}
//			System.out.println(S);
		}
	}
}
//  [cpp]
#include <cstdio>
#include <cstdlib>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a >= b && a >= c) printf("%d\n", b + c);
	else if (b >= a && b >= c) printf("%d\n", a + c);
	else if (c >= a && c >= b) printf("%d\n", a + b);
	return 0;
}
//  [cpp]
#include<stdio.h>

int main()
{
	int a, b, c,d;
	scanf("%d %d %d",&a,&b,&c);
	if (a >= b) {
		d = a;
		a = b;
		b = d;
	}
	if (b >= c) {
		d = b;
		b = c;
		c = d;
	}
	printf("%d", a + b);
    return 0;
}
//  [cpp]
#include <stdio.h>
int main(void){
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
d = a+b;
if(d >=a+c){
	d = a+c;
}
if(d>=c+b){
	d = b+c;
}
printf("%d",d);
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <sstream>
#include <cstdlib>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define C(x) cout << x << endl //テスト出力

//DP処理用
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//関数
//nCkの計算の関数(呼び出しは[cbn])
ll cbn(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
// a^n mod を計算する
ll powmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//２つの最大公約数
int gcb(int a, int b){
    if(a < b){
        int x = a;
        a = b;
        b = x;
    }
    int amari = a % b;
    if(amari == 0) return b;

    return gcb(b, amari);
}
//３つの最大公約数
int gcb_3(int a, int b, int c){
    return gcb(gcb(a, b), c);
}

/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;
vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
sort(変数名.begin(), 変数名.end());*/

/*-----------------------------ここから-----------------------------*/

int main() {
cin.tie(0);
ios::sync_with_stdio(false);]
ll data[3];
REP(i,3) cin>>data[i];
sort(data.begin(),data.end());
cout<<data[0]+data[1];
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
      string s;
      cin >>s;
      s.pop_back();
      for(int i=0;i<200;i++){
        int n=s.size();
        if(n%2==1){
            s.pop_back();
            continue;
        }
        string a=s.substr(0,n/2) , b = s.substr(n/2,n/2);
        if(a==b){
            cout<<s.size()<<endl;
            return 0;
        }
        else{
            s.pop_back();
        }
     }   
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(a+b, max(a+c, b+c)) << endl;
}
//  [c]
#include <stdio.h>

int main(){
  int a[3];
  
  for(int i=0; i<3; i++)  scanf("%d", a+i);

  for(int i=0; i<2; i++)
    for(int j=i+1; j<3; j++)
      if(a[i] > a[j]){
	a[i] ^= a[j];
	a[j] ^= a[i];
	a[i] ^= a[j];
      }

  printf("%d\n", a[0]+a[1]);
  
  return 0;
}
//  [c]
#include<stdio.h>
int main(void){
    int a,b,c,ab,bc,ca;
    scanf("%d %d %d",&a,&b,&c);
    ab=a+b;
    bc=b+c;
    ca=c+a;
    if(ab<bc && ab<ca){
        printf("%d\n",ab);
    }else if(bc<ca){
        printf("%d\n",bc);
    }else{
        printf("%d\n",ca);
    }
    return 0;
}
//  [c]
#include <stdio.h>
int main(){
    
    int a,b,c,sum;
    scanf("%d %d %d",&a,&b,&c);
    sum=a+b;
    if(sum>a+c)sum=a+c;
    if(sum>b+c)sum=c+b;

    printf("%d\n",sum);
    
    return 0;
}
//  [c]
#include <stdio.h>
int main()
{
    int a, b, c, ab, ac, bc;
    scanf("%d %d %d", &a, &b, &c);
    ab = a+b;
    ac = a+c;
    bc = b+c;
    if(ab<ac && ab<bc)
    {
        printf("%d", ab);
    }
    else if(ac<ab && ac<bc)
    {
        printf("%d", ac);
    }
    else
    {
        printf("%d", bc);
    }
    return 0;
//  [c]
#include <stdio.h>

int main()
{
    int a, b, c, ab, ac, bc;
    scanf("%d %d %d", &a, &b, &c);

    ab = a+b;
    ac = a+c;
    bc = b+c;

    if(ab>ac && ab>bc)
    {
        printf("%d", ab);
    }
    else if(ac>ab && ac>bc)
    {
        printf("%d", ac);
    }
    else
    {
        printf("%d", bc);
    }

    return 0;
}
//  [c]
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if((a>=1 && a<=1000) && (b>=1 && b<=1000) && (c>=1 && c<=1000))
{
    if((a+b)<(a+c)&& (a+b)<(b+c)){
        printf("%d",(a+b));
    }
    else if((b+c)<(a+c)&& (b+c)<(a+b)){
        printf("%d",(b+c));
    }
    else{
        printf("%d",(a+c));
    }
}
return 0;
}
//  [javascript]
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
(function Main(input) {
  var money = input.split(/\s+/);
  for(var i = 0; i < money.length; i++) {
  money[i] = parseInt(money[i], 10);
  }
  var max = Math.max(money[0], money[1], money[2]);
  var min = Math.min(money[0], money[1], money[2]);
  var average = (money[0] + money[1] + money[2]) - max - min;
  console.log('%d', min + average);
})(input);
//  [javascript]
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
(function Main(input) {
  var money = input.split(/\s+/);
  for(var i = 0; i < money.length; i++) {
  money[i] = parseInt(money[i], 10);
  }
  var max = Math.max(money[0], money[1], money[2]);
  console.log('%d', money[0]+money[1]+money[2] - max);
})(input);
//  [javascript]
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const a = numbers[0];
  const b = numbers[1];
  const c = numbers[2];
  console.log(a + b + c - Math.max(...numbers))
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
const main = (input) => {
  const [a, b, c] = input.trim().split(" ").map(Number).sort();
  return a + b;
};
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [javascript]
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
  a.sort();
 console.log(a[0]+a[1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
(function Main(input) {
  var money = input.split(/\s+/);
  for(var i = 0; i < money.length; i++) {
  money[i] = parseInt(money[i], 10);
  }
  var max = Math.max(money[0], money[1], money[2]);
  console.log('%d', money[1]+money[2]+money[3] - max);
})(input);
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	nums := make([]int, 3)
	fmt.Scan(&nums[0], &nums[1], &nums[2])
	sort.IntSlice(nums).Sort()
	fmt.Println(nums[0] + nums[1])
}
//  [go]
package main

import "fmt"

func max(x ...int) int {
	mv := x[0]
	for _, v := range x[1:] {
		if v > mv {
			mv = v
		}
	}
	return mv
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(a + b + c - max(a, b, c))
}
//  [go]
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, c := getInt(), getInt(), getInt()

	out(min(a+b, min(a+c, b+c)))
}
//  [go]
package main

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

func main() {
	a := getInt()
	b := getInt()
	c := getInt()

	fmt.Println(sum(a, b, c) - min(a, b, c))
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func min(ns ...int) int {
	var min int
	min = ns[0]
	for _, n := range ns {
		if min > n {
			min = n
		}
	}
	return min
}
//  [go]
package main

import(
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	prices := strings.Split(sc.Text(), " ")
 	for i := 0;i < len(prices) - 1;i++ {
		for j := len(prices) - 1; j > 0; j-- {
			fastPrice,_ := strconv.Atoi(prices[i])
			lastPrice,_ := strconv.Atoi(prices[j])
			if fastPrice > lastPrice{
				t := prices[i]
				prices[i] = prices[j]
				prices[j] = t
			}
		}
	}
	fastPrice,_ := strconv.Atoi(prices[0])
	lastPrice,_ := strconv.Atoi(prices[1])
	println(fastPrice + lastPrice)
}
//  [go]
package main

import(
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	prices := strings.Split(sc.Text(), " ")
 	for i := 0;i < len(prices);i++ {
		for j := len(prices) - 1; j > 0; j-- {
			fastPrice,_ := strconv.Atoi(prices[i])
			lastPrice,_ := strconv.Atoi(prices[j])
			if(i == j) {
				break
			}
			if fastPrice > lastPrice{
				t := prices[i]
				prices[i] = prices[j]
				prices[j] = t
			}
		}
	}
	fastPrice,_ := strconv.Atoi(prices[0])
	lastPrice,_ := strconv.Atoi(prices[1])
	println(fastPrice + lastPrice)
}
//  [ruby]
puts gets.split.map(&:to_i).sort.take(2).reduce(:+)
//  [ruby]
a=gets.split.map(&:to_i).sort;puts a[0] + a[1]
//  [ruby]
def sum(arr)
  ans = 0
  for i in arr
    ans += i
  end
  return ans
end
a = gets.split(" ").map(&:to_i)
p(sum(a) - a.max())
//  [ruby]
arr = gets.chomp.split.map(&:to_i)
arrays = arr.combination(2).to_a
s = arrays.map {|a| a.sum}
a = s.sort.first
puts a
//  [ruby]
arr = gets.chomp.split.map(&:to_i)
arrays = arr.combination(2).to_a
s = arrays.map {|a| a.sum}
puts s.sort.first
//  [ruby]
def sum(arr)
  ans = 0
  for i in arr
    ans += i
  end
end
a = gets.split(" ").map(&:to_i)
p(sum(a) - a.max())
//  [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")
}

use std::cmp::max;

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    println!("{}", a + b+ c - max(a, max(b, c)));
}
//  [rust]
use std::io;
use std::cmp::min;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	println!("{}", min(min(a+b, a+c), b+c));
}
//  [rust]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut aa = get!(String).split_whitespace().map(|i| i.parse::<i32>().unwrap()).collect::<Vec<_>>();
    aa.sort();
    println!("{}", aa[0] + aa[1]);
}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut edges = vec![vec![]; n];
    for i in 0..m {
        let v = read_vec::<usize>();
        let (s, t) = (v[0] - 1, v[1] - 1);
        edges[s].push(t);
    }
    let mut dp = vec![0.0; n];
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    println!("{}", (a + b).min(b + c).min(c + a));
}
//  [rust]
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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 w = read::<i32>();
    let h = read::<i32>();
    let n = read::<usize>();
    let mut ps = vec![(0, 0); 2 * n];
    let mut online_ps = vec![];
    let mut online_cnt = vec![0; n];
    for i in 0..n {
        for j in 0..2 {
            let x = read::<i32>();
            let y = read::<i32>();
            ps[i * 2 + j] = (x, y);
            if x == 0 || y == 0 || x == w || y == h {
                let mut d = 0;
                if y == 0 {
                    d = x;
                } else if x == w {
                    d = w + y;
                } else if y == h {
                    d = w + h + (w - x);
                } else if x == 0 {
                    d = w + h + w + (h - y);
                }
                online_ps.push((d, i, x, y));
                online_cnt[i] += 1;
            }
        }
    }
    online_ps.sort();
    let mut stack = vec![];
    for &(_d, index, _x, _y) in online_ps.iter() {
        if online_cnt[index] == 1 {
            continue;
        }
        if let Some(&last_index) = stack.last() {
            if last_index == index {
                stack.pop();
                continue;
            }
        }
        stack.push(index);
    }
    println!("{}", if stack.len() == 0 { "YES" } else { "NO" });
}
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!}.sort();print(i[0]+i[1])
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!}.sort;print(i[0]+i[1])
//  [typescript]
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a:number[]=[];for(let i=0;i<arg;i++) {a.push(t.n());}return a;}else{const a = t.input[0];t.input.shift();return Number(a);}},s:(arg:number=0):any=>{if(arg){const a:string[]=[];for(let i=0;i<arg;i++){a.push(t.s());}return a;}else{const a=t.input[0];t.input.shift();return String(a);}},c:(arg:number=0):any=>{if(arg) {const a:string[]=[];for(let i=0;i<arg;i++) {a.push(t.c());}return a;}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('');}else{t.input.shift();}return String(b);}},o: (...arg)=>{console.log(...arg);},abs:(a)=>{return Math.abs(a);},min:(...a)=>{return Math.min(...a);},max:(...a)=>{return Math.max(...a);},floor:(a)=>{return Math.floor(a);},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b});},desc:(ar:number[])=>{ return ar.sort((a,b)=>{return b-a});},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1]}return arr[arr.length-1];}}
const main = ()=>{
  let [a,b,c] = t.n(3)
  t.o(t.min(a+b,b+c,a+c))
}
main()
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[2], 10);
  const result = [a,b,c];
  
  console.log(a+b+c-Math.max.apply(null, result));
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin.split('\n')[0].split(' ').map(Number)

const sorted = [a, b, c].sort((a, b)=> a-b)

console.log(sorted[0] + sorted[1])
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[1], 10);
  const result = [a,b,c];
  
  console.log(a+b+c-Math.max.apply(null, result));
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[1], 10);
  
  console.log(a+b+c-Math.max.apply(null,[a,b,c]));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[1], 10);
  
  console.log(a+b+c-Math.max(a,b,c));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A1 = [int(x) for x in input().split()]
    A2 = [int(x) for x in input().split()]
    A3 = [int(x) for x in input().split()]
    N = int(input())
    A = set([int(input()) for _ in range(N)])
    f = False
    if A1[0] in A and A1[1] in A and A1[2] in A:
        print("Yes")
        return
    if A2[0] in A and A2[1] in A and A2[2] in A:
        print("Yes")
        return
    if A3[0] in A and A3[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[0] in A and A3[0] in A:
        print("Yes")
        return
    if A1[1] in A and A2[1] in A and A3[1] in A:
        print("Yes")
        return
    if A1[2] in A and A2[2] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[2] in A and A2[1] in A and A3[0] in A:
        print("Yes")
        return
    print("No")

    
    
    



if __name__ == '__main__':
    main()
//  [python]
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

c = [[0]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                c[i][j] = 1

for i in range(3):
    if c[i][0] and c[i][1] and c[i][2]:
        print('Yes')
        exit()
    if c[0][i] and c[1][i] and c[2][i]:
        print('Yes')
        exit()
if c[0][0] and c[1][1] and c[2][2]:
    print('Yes')
    exit()
if c[0][2] and c[1][1] and c[2][0]:
    print('Yes')
    exit()
print('No')
//  [python]
# coding: utf-8
# Your code here!

a = []
a.append(list(input().split()))
a.append(list(input().split()))
a.append(list(input().split()))

def kezuru(b):
    for i in range(len(a)):
        for j in range(len(a[i])):
            if b == a[i][j]:
                a[i][j] = '*'
        

n = int(input())
for i in range(n):
    b = input()
    kezuru(b)
    
def check():
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2]:
            return 'Yes'
    for i in range(3):
        if a[0][i] == a[1][i] and a[0][i] == a[2][i]:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2]:
        return 'Yes'
    if a[0][2] == a[1][1] and a[0][2] == a[2][0]:
        return 'Yes'
    return 'No'
    
print(check())
//  [python]
def Judge(a):
  col=[]
  diag1=0
  diag2=0

  for i in range(3):
    if(a[i].count(0)==3):
      return 1
      break
    if(a[0][i]==0):
      col.append(0)
    if(a[1][i]==0):
      col.append(1)
    if(a[2][i]==0):
      col.append(2)
    if(a[i][i]==0):
      diag1+=1
    if(a[i][-(i+1)]==0):
      diag2+=1
  if(diag1==3 or diag2==3):
    return 1
  if(col.count(0)==3 or col.count(1)==3 or col.count(2)==3):
    return 1
  return 0


a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if(b==a[j][k]):
        a[j][k]=0
judge=Judge(a)
if(judge==1):
  print("Yes")
else:
  print("No")
//  [python]
lst = [ [ int(i) for i in input().split() ] for j in range(3) ]

n = int(input())

for _ in range(n):
  x = int(input())
  for d in lst:
    if d[0] == x:
      d[0] = -1
    elif d[1] == x:
      d[1] = -1
    elif d[2] == x:
      d[2] = -1
print(lst)
for d in lst:
  if d[0] == d[1] == d[2] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[0][i] == lst[1][i] == lst[2][i] == -1:
    print('Yes')
    exit()
for i in range(3):
  if lst[i][0] == lst[i][1] == lst[i][2] == -1:
    print('Yes')
    exit()
if lst[0][0] == lst[1][1] == lst[2][2] == -1:
  print('Yes')
  exit()
if lst[0][2] == lst[1][1] == lst[2][0] == -1:
  print('Yes')
  exit()
print('No')
//  [python]
lst = [ [ int(i) for i in input().split() ] for j in range(3) ]

n = int(input())

for _ in range(n):
  x = int(input())
  for d in lst:
    if d[0] == x:
      d[0] = -1
    elif d[1] == x:
      d[1] = -1
    elif d[2] == x:
      d[2] = -1
for d in lst:
  if d[0] == d[1] == d[2] == -1:
    print('Yes')
    exit()
    
for i in range(3):
  if lst[i][0] == lst[i][1] == lst[i][2] == -1:
    print('Yes')
    exit()
if lst[0][0] == lst[1][1] == lst[2][2] == -1:
  print('Yes')
  exit()
if lst[0][2] == lst[1][1] == lst[2][0] == -1:
  print('Yes')
  exit()
print('No')
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int[][] A=new int[3][3];
		for(int i=0;i<3;++i)for(int j=0;j<3;++j)A[i][j]=sc.nextInt();
		int n=sc.nextInt();
		int[] b=new int[n];
		HashSet<Integer> set=new HashSet<>();
		for(int i=0;i<n;++i) {
			b[i]=sc.nextInt();
			set.add(b[i]);
		}
		boolean[][] a=new boolean[3][3];
		for(int i=0;i<3;++i)
			for(int j=0;j<3;++j) a[i][j]|=set.contains(A[i][j]);
		boolean ans=false;
		for(int i=0;i<3;++i) {
			ans|=a[i][0]&&a[i][1]&&a[i][2];
		}
		for(int i=0;i<3;++i) {
			ans|=a[0][i]&&a[1][i]&&a[2][i];
		}
		ans|=a[0][0]&&a[1][1]&&a[2][2];
		ans|=a[2][0]&&a[1][1]&&a[0][2];
		System.out.println(ans?"Yes":"No");
	}
	
	static void tr(Object... objects) {
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		boolean[][] c = new boolean[3][3];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (b[i] == a[j][k]) {
						c[j][k] = true;
						break;
					}
				}
			}
		}

		boolean k = false;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (!c[i][j]) {
					k = false;
					break;
				} else {
					k = true;
				}
			}
		}
		if (k) {
			System.out.println("Yes");
			return;
		}

		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < 3; i++) {
				if (!c[i][j]) {
					k = false;
					break;
				} else {
					k = true;
				}
			}
		}

		if ( (c[0][0] && c[1][1] && c[2][2]) || c[0][2] && c[1][1] && c[2][0] ) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");
		return;

	}

}
//  [java]
import java.util.LinkedHashSet;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    private static final int TOTAL_NUM = 13;

    private static final String HEART = "H";
    private static final String DIAMOND = "D";
    private static final String SPADE = "S";
    private static final String CLUB = "C";

    private static Set mapCardHeart = new LinkedHashSet();
    private static Set mapCardDiamond = new LinkedHashSet();
    private static Set mapCardSpade = new LinkedHashSet();
    private static Set mapCardClub = new LinkedHashSet();

    // Mapだと上書きされちゃう！！
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int iCardNum = Integer.parseInt(sc.next());
        readCard(iCardNum);
        output();
    }

    private static void readCard(final int iCardNum) {
        final Scanner sc = new Scanner(System.in);
        for (int i = 0; i < iCardNum; i++) {
            final String sCardType = sc.next();
            final int iCardVal = Integer.parseInt(sc.next());
            procSelectCardType(sCardType, iCardVal);
        }
    }

    private static String convOutput(final String sCardType, final int iCardVal) {
        final StringBuilder sb = new StringBuilder();
        sb.append(sCardType);
        sb.append(" ");
        sb.append(iCardVal);
        return sb.toString();
    }

    private final static void procSelectCardType(final String sCardType, final int iCardVal) {
        switch (sCardType) {
            case HEART:
                setHeart(iCardVal);
                break;

            case DIAMOND:
                setDiamond(iCardVal);
                break;

            case SPADE:
                setSpade(iCardVal);
                break;

            case CLUB:
                setClub(iCardVal);
                break;

            default:
                break;
        }
    }

    private static void output() {
        String sOut = "";
        if (!mapCardHeart.isEmpty()) {
            final int iNotCnt = TOTAL_NUM - mapCardHeart.size();
            sOut += convOutput(HEART, iNotCnt);
        }
        if (!mapCardDiamond.isEmpty()) {
            final int iNotCnt = TOTAL_NUM - mapCardDiamond.size();
            sOut += convOutput(DIAMOND, iNotCnt);
        }

        if (!mapCardSpade.isEmpty()) {
            final int iNotCnt = TOTAL_NUM - mapCardSpade.size();
            sOut += convOutput(SPADE, iNotCnt);
        }

        if (!mapCardClub.isEmpty()) {
            final int iNotCnt = TOTAL_NUM - mapCardClub.size();
            sOut += convOutput(CLUB, iNotCnt);
        }
        System.out.println(sOut);
    }

    private static void setHeart(final int iCardVal) {
        mapCardHeart.add(iCardVal);
    }

    private static void setDiamond(final int iCardVal) {
        mapCardDiamond.add(iCardVal)
    }

    private static void setSpade(final int iCardVal) {
        mapCardSpade.add(iCardVal);
    }

    private static void setClub(final int iCardVal) {
        mapCardClub.add(iCardVal);
    }

}
//  [java]


import java.util.Scanner;

// 7
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                a[i][j] = sc.nextInt();
        int N = sc.nextInt();
        int[] b = new int[N];
        for(int i = 0; i < N; i++)
            b[i] = sc.nextInt();

        int count = 0;
        //if count >= 6 then break
        int i, j, k = 0;
        for(i = 0; i < 3; i++)
            for(j = 0; j < 3; j++) {
                for(k = 0; k < N; k++) {
                    if(b[k] == a[i][j]) {
                        a[i][j] = -1;
                        ++count;
                        if(count == 6) {
                            i = j = k = 10;
                            System.out.println("Yes");
                        }
                    }
                }
            }

        String ans = "No";
        if(i != 3) {
            for(int ii = 0; ii < 3; ii++)
                if(a[ii][0] == -1 && a[ii][1] == -1 && a[ii][2] == -1) {
                    ans = "Yes";
                    break;
                }
            for(int jj = 0; jj < 3; jj++)
                if(a[0][jj] == -1 && a[1][jj] == -1 && a[2][jj] == -1) {
                    ans = "Yes";
                    break;
                }

            if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) {
                ans = "Yes";
            }
            if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) {
                ans = "Yes";
            }
            System.out.println(ans);
        }
    }

}
//  [cpp]
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll ans[3][3], memo[3][3];
  rep(i,3){
    rep(j,3){
      cin>>ans[i][j];
      memo[i][j] = 0;
    }
  }
  ll n;cin>>n;
  rep(i,n){
    ll b;cin>>b;
    rep(y,3){
      rep(x,3){
        if(ans[y][x] == b){
          memo[y][x] = 1;
        }
      }
    }
  }

  rep(i,3){
    if(memo[i][0] && memo[i][1] && memo[i][2]){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(memo[0][i] && memo[1][i] && memo[2][i]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(memo[0][0] && memo[1][1] && memo[2][2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(memo[0][2] && memo[1][1] && memo[2][0]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int A[3][3];
int N;
bool done[3][3];

int main() {
	REP(i, 3) REP(j, 3) cin >> A[i][j];
	cin >> N;
	REP(i, N) {
		int b;
		cin >> b;
		REP(j, N) REP(k, N) if (A[j][k] == b) done[j][k] = true;
	}
	
	bool ans = false;
	REP(i, 3) {
		bool cur = true;
		REP(j, 3) if (!done[i][j]) cur = false;
		ans |= cur;
		
		cur = true;
		REP(j, 3) if (!done[j][i]) cur = false;
		ans |= cur;
	}
	
	bool cur = true;
	REP(i, 3) {
		if (!done[i][i]) cur = false;
	}
	ans |= cur;
	
	cur = true;
	REP(i, 3) if (!done[i][2 - i]) cur = false;
	ans |= cur;
	
	puts([&] {
		return ans;
	}() ? "Yes": "No");
	
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int a[3][3];
    bool b[3][3];
    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> a[i][j];
            b[i][j] = false;
        }
    }

    int n;
    cin >> n;
    REP(k, n)
    {
        int c;
        cin >> c;
        REP(i, 3)
        REP(j, 3)
        if (a[i][j] == c) {
            b[i][j] = true;
        }
    }
    if((b[0][0]&&b[0][1]&&b[0][2])||
    (b[1][0]&&b[1][1]&&b[1][2])||
    (b[2][0]&&b[2][1]&&b[2][2])||
    (b[0][0]&&b[1][0]&&b[2][0])||
    (b[0][1]&&b[1][1]&&b[2][1])||
    (b[0][2]&&b[1][2]&&b[2][2])||
    (b[0][0]&&b[1][1]&&b[2][2])||
    (b[0][2]&&b[1][1]&&b[2][2]))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
    
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int solve(){
  int a[9];
  for(int i=0; i<9; i++){
    cin>>a[i];
  }
  int n; cin>>n;
  for(int i=0; i<n; i++){
    int x; cin>>x;
    for(int j=0; j<9; j++){
      if(a[j] == x){
        a[j]= -1;
        break;
      }
    }
  }
  for(int i=0; i<3; i++){
    if(a[i] + a[i+3] + a[i+6] == -3){
      return 2;
    }else if(a[i] + a[i+1] + a[i+2] == -3){
      return 2;
    }
  }
  if(a[0] + a[4] + a[8] == -3) return 2;
  if(a[2] + a[4] + a[6] == -3) return 2;

  return 1;
  
}

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  int s = solve();
  if(s == 1){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
}