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

func main() {
    let st = readLine()!.split(separator: " ")
    let s = st[0]
    // let t = st[1]

    let ab = readInts()
    let a = ab[0]
    let b = ab[1]

    let u = readLine()!

    if u == s {
        print(a - 1, b)
    } else {
        print(a, b - 1)
    }
}

main()


import Foundation

let input_line = readLine()!

var split = input_line.componentsSeparatedByString(" ")
let S = split[0]
let T = split[1]

//標準入力二行
let input_line2 = readLine()!
split = input_line2.componentsSeparatedByString(" ")
var A = Int(split[0])!
var B = Int(split[1])!

//標準入力二行
let U = readLine()!

if U == S {
  A -= 1
} else {
  B -= 1
}
print(A, B)


import Foundation

let N = Int(readLine()!)!
var array =  readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
var answer = "YES"
_ = array.map {
    //array.remove(value: $0)
	if let i = array.indexOf($0) {
        array.removeAtIndex(i)
    }
    if array.contains($0) {
        answer = "NO"
    }
}
print(answer)


import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8");
const [colors, nums, u] = input.split("\n")
const [s, t] = colors.split(" ")
let [a, b] = nums.split(" ").map(x => +x)

if (u === s) a--
if (u === t) b--

console.log(a, b)


import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

const [s, t] = input[0].split(' ');
const [a, b] = input[1].split(' ').map((x : string): number => +x);
const u = input[2];

if (u===s){
	console.log(a-1, b);
}else{
	console.log(a,b-1);
}


class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}

const o = new AtCoder()
let [a,b]=[...o.ss(2)]
let [n,m]=[...o.nn(2)]
let c=o.s()

if(a==c){
  o.o(n-1+" "+m)
}else{
  o.o(n, m-1)
}


import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

const [s, t] = input[0].split(' ');
const [a, b] = input[1].split(' ').map((x : string): number => +x);
const u = input[2];

if (u==='red'){
	console.log(a-1, b);
}else{
	console.log(a,b-1);
}


import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

const [s, t] = input[0].split(' ');
const [a, b] = input[1].split(' ').map((x : string): number => +x);
const u = input[2];

if (u==='red'){
	console.log(a-1, b);
}else if (u==='blue'){
	console.log(a,b-1);
}else{
	console.log(a,b);
}


c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

diff1 = c21 - c11
diff2 = c31 - c21
if diff1 == (c22-c12) and diff2 == (c32-c22) and diff1 == (c23-c13) and diff2 == (c33-c23):
    print("Yes")
else:
    print("No")


c = [list(map(int,input().split())) for _ in range(3)]

e = c[0][1] - c[0][0]
f = c[0][2] - c[0][1]

if any(e != c[x][1]-c[x][0] for x in [1,2]) or any(f != c[x][2]-c[x][1] for x in [1,2]) :
    print('No')
else:
    print('Yes')


c = [list(map(int, input().split())) for _ in range(3)]
def a(c):
    for j in range(2):
        if not ((c[0][j]-c[0][j+1]) == (c[1][j]-c[1][j+1]) and (c[1][j]-c[1][j+1]) == (c[2][j]-c[2][j+1])):
            return print('No')
        if not ((c[j][0]-c[j+1][0]) == (c[j][1]-c[j+1][1]) and (c[j][1]-c[j+1][1]) == (c[j][2]-c[j+1][2])):
            return print('No')
    return print('Yes')
a(c)


c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

a1_a2 = c1[0] - c2[0]
a2_a3 = c2[0] - c3[0]
b1_b2 = c1[0] - c1[1]
b2_b3 = c1[1] - c1[2]

cnt = 0
if a1_a2 == c1[1]-c2[1] == c1[2]-c2[2]:
    cnt += 1
if a2_a3 == c2[1]-c3[1] == c2[2]-c3[2]:
    cnt += 1
if b1_b2 == c2[0]-c2[1] == c3[0]-c3[1]:
    cnt += 1
if b2_b3 == c2[1]-c2[2] == c3[1]-c2[2]:
    cnt += 1

if cnt == 4:
    print("Yes")
else:
    print("No")


c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
if (sum(c1)+sum(c2)+sum(c3))%3 == 0:
    print("Yes")
else:
    print("No")


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

c = []
for i in range(3):
    c.append(list(map(int, input().split())))

for a1 in range(1, 101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    for a2 in range(1, 101):
        if not (b1 == (c[1][0] - a2) and b2 == (c[1][1] - a2) and b3 == (c[1][2] - a2)):
            continue
        for a3 in range(1, 101):
            if (b1 == (c[2][0] - a3) and b2 == (c[2][1] - a3) and b3 == (c[2][2] - a3)):
                print('Yes')
                sys.exit(0)
print('No')


import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}

	public void debug() {
	}

	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);

	int[][] c = new int[3][3];

//	int ans = -1;
	boolean ans = true;

	public void input() throws IOException {
		for (int i=0; i<3; i++) {
			for (int j=0; j<3; j++) {
				c[i][j] = in.nextInt();
			}
		}
	}

	public void solve() throws IOException {
		for (int i=0; i<2; i++) {
			int dj0 = c[i+1][0]-c[i][0];
			int dj1 = c[i+1][1]-c[i][1];
			int dj2 = c[i+1][2]-c[i][2];
			if (dj0 != dj1 || dj1 != dj2) {
				ans = false;
				return;
			}
		}
		for (int j=0; j<2; j++) {
			int di0 = c[0][j+1]-c[0][j];
			int di1 = c[1][j+1]-c[1][j];
			int di2 = c[2][j+1]-c[2][j];
			if (di0 != di1 || di1 != di2) {
				ans = false;
				return;
			}
		}
	}

	public void output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
	}
}

class Point {
	int y;
	int x;
	public Point(int y, int x) {
		this.x=x;
		this.y=y;
	}

	public Point move(Point d) {
		Point p = new Point(y, x);
		p.x += d.x;
		p.y += d.y;
		return p;
	}

}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;

	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}

	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}

	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}

	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c))
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}

	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}

	//Close
	public void close() throws IOException {
		if(!this.in.equals(System.in))
			this.in.close();
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner();
        int[][] c=new int[3][3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                c[i][j]=scanner.nextInt();
            }
        }
        int[] a=new int[3];
        int[] b=new int[3];
        for(int i=0;i<3;i++){
            b[i]=c[0][i];
        }
        a[1]=c[1][1]-b[1];
        a[2]=c[2][2]-b[2];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(c[i][j]!=a[i]+b[j]){
                    put("No");
                    return;
                }
            }
        }
        put("Yes");

    }

    public static void put(Object object) {
        System.out.println(object);
    }
    public static String format(String string, Object... args) {
        return String.format(string, args);
    }
}

final class Scanner {
    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 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());
    }
}

final class Pair {
    final public int x, y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public int hashCode() {
        return x+y;
    }

    @Override
    public boolean equals(Object obj) {
        boolean result=super.equals(obj);
        if(obj.getClass()!=this.getClass()){
            return false;
        }
        Pair pair=(Pair)obj;
        if(this.x==pair.x&&this.y==pair.y) return true;
        return false;
    }

    @Override
    public String toString() {
        return String.format("(%d,%d)", x, y);
    }
}
final class Tuple<T,V>{
    final public T t;
    final public V v;
    Tuple(T t,V v){
        this.t=t;
        this.v=v;
    }

    @Override
    public int hashCode() {
        return (t.hashCode()+v.hashCode());
    }

    @Override
    public boolean equals(Object obj) {
        if(obj.getClass()!=this.getClass()){
            return false;
        }
        Tuple<T,V> tuple=(Tuple)obj;
        return tuple.t.equals(this.t)&&tuple.v.equals(this.v);
    }

    @Override
    public String toString() {
        return String.format("<Tuple>=<%s,%s>",t,v);
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();

    	int c11 = sc.nextInt();
    	int c12 = sc.nextInt();
    	int c13 = sc.nextInt();
    	int c21 = sc.nextInt();
    	int c22 = sc.nextInt();
    	int c23 = sc.nextInt();
    	int c31 = sc.nextInt();
    	int c32 = sc.nextInt();
    	int c33 = sc.nextInt();

    	int b1 = c11;
    	int b2 = c12;
    	int b3 = c13;
    	int a2 = c21 - b1;
    	int a3 = c31 - b1;

    	boolean can = true;

    	if(c22!=a2+b2 || c23!= a2+b3 || c32!= a3+b2 || c33!= a3+b3){
    		can = false;
    	}

    	if(can){
        	System.out.println("Yes");
    	}
    	else{
        	System.out.println("No");
    	}
    }

}

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        int[][] cs = new int[3][3];
        cs[0] = reader.readInts(" ");
        cs[1] = reader.readInts(" ");
        cs[2] = reader.readInts(" ");
        System.out.println(problem088c(cs));
    }

    private static String problem088c(int[][] cs) {
        int[] as = {-1, -1, -1};
        int[] bs = {-1, -1, -1};

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                int n = cs[i][j];
                as[i] = Math.max(as[i], n);
                bs[j] = Math.max(bs[j], n);
            }
        }

        int a, b;
        for (int a1 = 0; a1 <= as[0]; a1++) {
            for (int a2 = 0; a2 <= as[1]; a2++) {
                for (int a3 = 0; a3 <= as[2]; a3++) {
                    for (int b1 = 0; b1 <= bs[0]; b1++) {
                        for (int b2 = 0; b2 <= bs[1]; b2++) {
                            whole:
                            for (int b3 = 0; b3 <= bs[2]; b3++) {
                                for (int i = 0; i < 3; i++) {
                                    a = (i == 0) ? a1 : ((i == 1) ? a2 : a3);
                                    for (int j = 0; j < 3; j++) {
                                        b = (j == 0) ? b1 : ((j == 1) ? b2 : b3);
                                        if ((a + b) != cs[i][j]) continue whole;
                                    }
                                }
                                return  "Yes";
                            }
                        }
                    }
                }
            }
        }
        return "No";
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readString() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readString());
        }

        private String[] readStrings(String regex) throws IOException {
            return readString().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }
    }
}


import java.util.*;
class Main{
  static Scanner sc=new Scanner(System.in);
  public static void main(String args[]){
    int c[][] = new int[3][3];
    boolean F=false;
    for(int i=0;i<3;++i){
      for(int j=0;j<3;++j){
        c[i][j]=sc.nextInt();
      }
    }
    for(int a1=0;a1<=50&&!F;a1++){
      for(int a2=0;a2<=50&&!F;a2++){
        for(int a3=0;a3<=50&&!F;a3++){
          int b1=c[0][0]-a1,b2=c[0][1]-a1,b3=c[0][2]-a1;
          boolean L2,L3;
          L2=(c[1][0]==a2+b1&&c[1][1]==a2+b2&&c[1][2]==a2+b3);
          L3=(c[2][0]==a3+b1&&c[2][1]==a3+b2&&c[2][2]==a3+b3);
          F=L2&&L3;
        }
      }
    }
    System.out.println(F?"Yes":"No");
  }
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int[][] c = new int[3][3];
    int maxind = 0;
    int max = 0;

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

    while (true) {
      max = 0;
      maxind = 0;
      boolean ok = true;
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (max < c[i][j]) {
            max = c[i][j];
            maxind = i;
          }
        }
      }

      for (int j = 0; j < 3; j++) {
        c[maxind][j] = Math.max(c[maxind][j] - 1, 0);
      }

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

      if (ok) {
        System.out.println("No");
        return;
      }

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

    }

  }
}


#include <iostream>
using namespace std;

int main() {
  int c[9];
  for(int i = 0; i < sizeof(c); i++) cin >> c[i];
  cout << (c[0]+c[4]+c[8] == c[1]+c[5]+c[6] && c[0]+c[4]+c[8] == c[2]+c[3]+c[7] ? "Yes" : "No") <<endl;
}


#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int c[3][3];
    int b1,b2,b3;
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin>>c[i][j];
        }
    }
    bool ret = false;
    for(int a1=0;a1<=100;++a1){
        b1=c[0][0]-a1;
        b2=c[0][1]-a1;
        b3=c[0][2]-a1;
        if(b1<0 || b2<0 || b3<0)break;
        for(int a2=0;a2<=100;++a2){
            if(c[1][0]==a2+b1 && c[1][1]==a2+b2 && c[1][2]==a2+b3){
                for(int a3=0;a3<=100;++a3){
                    if(c[2][0]==a3+b1 && c[2][1]==a3+b2 && c[2][2]==a3+b3){
                        ret = true;
                        break;
                    }
                }
            }
            if(ret)break;
        }
        if(ret)break;
    }
    ret ==true ? cout<<"Yes"<<endl : cout << "No"<< endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#define INF 1000000000
using namespace std;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
		a[i][1] -= a[i][0];
		a[i][2] -= a[i][0];
		a[i][0] = 0;
	}
	for (int i = 0; i < 3; i++) {
		if (!(a[0][i] == a[1][i] && a[1][i] == a[2][i])) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main () {
	long long  c[3][3];
	long long  a[3]={0};
	long long b[3]={0};
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			cin >> c[i][j];
		}
	}
	b[1] = c[1][1];
	b[2] = c[1][2];
	b[3] = c[1][3];
	a[1] = 0;
	a[2] = c[2][2] - b[2];
	a[3] = c[3][3] - b[3];
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			if (c[i][j]!=a[i]+b[j]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main () {
	int c[3][3];
	int a[3]={0};
	int b[3]={0};
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			cin >> c[i][j];
		}
	}
	b[1] = c[1][1];
	b[2] = c[1][2];
	b[3] = c[1][3];
	a[1] = 0;
	a[2] = c[2][2] - b[2];
	a[3] = c[3][3] - b[3];
	for (int i=1; i<=3; i++) {
		for (int j=1; j<=3; j++) {
			if (c[i][j]!=a[i]+b[j]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


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

int main() {
  int sum = 0;
  rep(i,3)rep(j,3) {
    int c;
    cin >> c;
    sum += c;
  }
  if(sum % 3 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


#include <stdio.h>
int main(void){

    int c[3][3];
    for(int i=0;i<3;++i){
        for(int l=0;l<3;++l){
            int a;
            scanf("%d",&a);
            c[i][l] = a;
        }
    }
    if(c[0][0] + c[1][1] ==  c[0][1] + c[1][0]){
        if(c[1][0] + c[2][1] ==  c[2][0] + c[1][1]){
            if(c[0][1] + c[1][2] ==  c[0][2] + c[1][1]){
                if(c[1][1] + c[2][2] ==  c[1][2] + c[2][1]){
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}


#include<stdio.h>
int main(void){
	int c[3][4]={0},i,j;
	for(i=1;i<4;i++){
		for(j=1;j<4;j++){
			scanf("%d",&c[i][j]);
		}
	}
	for(i=1;i<3;i++){
		for(j=i;j<4;j++){
			if(c[i][i]+c[j][j]-c[i][j]-c[j][i]){
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    // ll n,ans=0;
    // scanf("%lld",&n);
    ll c[3][3],a[3],b[3];
    rep(i,0,3){
        rep(j,0,3) scanf("%lld",&c[i][j]);
    }
    a[0]=0;
    rep(i,0,3){
        b[i]=c[0][i]-a[0];
    }
    rep(i,1,3){
        a[i]=c[i][0]-b[0];
    }
    if(c[1][1]==a[1]+b[1] && c[1][2]==a[1]+b[2] && c[2][1]==a[2]+b[1] && c[2][2]==a[2]+b[2]){
        YES;
    }else{
        NO;
    }

    // printf("%lld\n");
    return 0;
}


#include <stdio.h>
int main(void){
  int a11,a12,a13,a21,a22,a23,a31,a32,a33,i,j,k,l;
  scanf("%d %d %d \n %d %d %d \n %d %d %d",&a11,&a12,&a13,&a21,&a22,&a23,&a31,&a32,&a33);
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      for(k=0;k<101;k++){
        for(l=0;l<101;l++){
          if(i==a12 && j==a13 && k==a21 && l==a31){
            printf("Yes\n");
          }
        }
      }
    }
  }
  printf("No\n");
  return 0;
}


#include <stdio.h>
int main(void){
  int a11,a12,a13,a21,a22,a23,a31,a32,a33,i,j,k,l;
  scanf("%d %d %d %d %d %d %d %d %d",&a11,&a12,&a13,&a21,&a22,&a23,&a31,&a32,&a33);
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      for(k=0;k<101;k++){
        for(l=0;l<101;l++){
          if(i==a12 && j==a13 && k==a21 && l==a31){
            printf("Yes\n");
          }
        }
      }
    }
  }
  printf("No\n");
  return 0;
}


#include <stdio.h>

int main()
{
    int c[4][4];
    int i, j;

    for(i=1; i<4; i++){
        for(j=1; j<4; j++){
            scanf("%d", &c[i][j]);
        }
    }

    if(c[1][1]-c[1][2] != c[2][1]-c[2][2]) {
        printf("no\n");
        return 0;
    }if(c[1][1]-c[1][3] != c[2][1]-c[2][3]) {
        printf("no\n");
        return 0;
    }if(c[1][2]-c[1][3] != c[2][2]-c[2][3]) {
        printf("no\n");
        return 0;
     }if(c[1][1]-c[1][2] != c[3][1]-c[3][2]) {
        printf("no\n");
        return 0;
     }if(c[1][1]-c[1][3] != c[3][1]-c[3][3]) {
        printf("no\n");
        return 0;
    }if(c[1][2]-c[1][3] != c[3][2]-c[3][3]) {
        printf("no\n");
        return 0;
    }if(c[2][1]-c[2][2] != c[3][1]-c[3][2]) {
        printf("no\n");
        return 0;
    }if(c[2][1]-c[2][3] != c[3][1]-c[3][3]) {
        printf("no\n");
        return 0;
    }if(c[2][2]-c[2][3] != c[3][2]-c[3][3]) {
        printf("no\n");
        return 0;
    }
    printf("yes\n");
    return 0;
}


function Main(input) {
    var c1 = changeNumber(input.split('\n')[0].split(' '));
    var c2 = changeNumber(input.split('\n')[1].split(' '));
    var c3 = changeNumber(input.split('\n')[2].split(' '));
    function changeNumber(c){
        var box =[];
        for(var k =0; k<3; k++){
            box.push(Number(c[k]));
        }
        return box;
    }
    var c = [];
    c.push(c1);
    c.push(c2);
    c.push(c3);
    var ans="No";
    if(c[2][2]-c[1][2]===c[2][1]-c[1][1]&&
       c[2][1]-c[1][1]===c[2][0]-c[1][0]&&
       c[1][2]-c[0][2]===c[1][1]-c[0][1]&&
       c[1][1]-c[0][1]===c[1][0]-c[0][0]&&
       c[0][2]-c[0][1]===c[1][2]-c[1][1]&&
       c[1][2]-c[1][1]===c[2][2]-c[2][1]&&
       c[0][1]-c[0][0]===c[1][1]-c[1][0]&&
       c[1][1]-c[1][0]===c[2][1]-c[2][0]){
    ans="Yes";
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict"
function Main(input) {
  input = input.trim().split('\n');
  let h = input[0].trim().split(' ').map(Number);
  let m = input[1].trim().split(' ').map(Number);
  let l = input[2].trim().split(' ').map(Number);

  let x = [m[0]-h[0], m[1]-h[1], m[2]-h[2]]
  let y = [l[0]-m[0], l[1]-m[1], l[2]-m[2]]

  if(x[0] === x[1] && x[1] === x[2]){
    if(y[0] === y[1] && y[1] === y[2]){
      console.log('Yes');
      return;
    }
  }
  console.log('No');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'

function main(input) {
  const lines = input.split('\n');

  const c = [];
  for(let i=0;i<3;i++){
    c.push(lines[i].split(' ').map(x => parseInt(x)))
  }

  let result = 'Yes';

  if(c[1][1]+c[2][2] != c[1][2]+c[2][1]){result='No';}
  if(c[0][0]+c[1][1] != c[0][1]+c[1][0]){result='No';}
  if(c[0][0]+c[2][2] != c[0][2]+c[2][0]){result='No';}

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var c = lines.map(i => i.split(" ").map(i => Number(i)));

    // Aiを表す
    for (var a1 = 0; a1 < 100; a1++) {
        var b1 = c[0][0] - a1
        var b2 = c[1][0] - a1
        var b3 = c[2][0] - a1

        // Biを表す
        for (var a2 = 0; a2 < 100; a2++) {
            if (a2 + b1 !== c[0][1]) { continue }
            if (a2 + b2 !== c[1][1]) { continue }
            if (a2 + b3 !== c[2][1]) { continue }

            // Ciを表す
            for (var a3 = 0; a3 < 100; a3++) {
                if (a3 + b1 !== c[0][2]) { continue }
                if (a3 + b2 !== c[1][2]) { continue }
                if (a3 + b3 !== c[2][2]) { continue }

                console.log("Yes");
                return (0)
            }
        }
    }
    console.log("No")

});


// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var c = [];
	c[0] = line[0].split(" ");
	c[1] = line[1].split(" ");
	c[2] = line[2].split(" ");
	var sum = 0;
	for(var i = 0; i < c.length; i++){
		for(var j = 0; j < c[i].length; j++){
			c[i][j] = Number(c[i][j]);
			sum += c[i][j];
		}
	}
	if(sum%3 !== 0){
		console.log('No');
	} else{
		var difcol = [c[0][1]-c[0][0], c[0][2]-c[0][1]];
		var difrow = [c[1][0]-c[0][0], c[2][0]-c[1][0]];
		if(c[1][1]-c[1][0] !== difcol[0] || c[1][2]-c[1][0] !== difcol[1]){
			console.log('No');
		} else if(c[2][1]-c[2][0] !== difcol[0] || c[2][2]-c[2][1] !== difcol[1]){
			console.log('No');
		} else if(c[1][1]-c[0][1] !== difrow[0] || c[2][1]-c[1][1] !== difrow[1]){
			console.log('No');
		} else if(c[1][2]-c[0][2] !== difrow[0] || c[2][2]-c[1][2] !== difrow[1]){
			console.log('No');
		} else{
			console.log('Yes');
		}
	}
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


var box = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n').map(e => e.split(' ').map(e => parseInt(e)));
var a = [Math.min(box[0][0], box[0][1], box[0][2]), Math.min(box[1][0], box[1][1], box[1][2]), Math.min(box[2][0], box[2][1], box[2][2])];
var b = [Math.min(box[0][0], box[1][0], box[2][0]), Math.min(box[0][1], box[1][1], box[2][1]), Math.min(box[0][2], box[1][2], box[2][2])];
var res = 'Yes';
for (var i = 0; res !='No' && i < 3; i++) for (var j = 0; res !='No' && j < 3; j++) box[i][j] != (a[i] + b[j]) ? res = 'No':'';
console.log(res);


package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var c [][]int

func main() {
	sc.Split(bufio.ScanWords)
	c = make([][]int, 3)
	for i := 0; i < 3; i++ {
		c[i] = []int{nextInt(), nextInt(), nextInt()}
	}

	ans := "No"

	for a1 := 0; a1 <= 100; a1++ {
		b1 := c[0][0] - a1
		b2 := c[0][1] - a1
		b3 := c[0][2] - a1
		if b1 < 0 || b2 < 0 || b3 < 0 {
			continue
		}
		if c[1][0]-b1 != c[1][1]-b2 || c[1][1]-b2 != c[1][2]-b3 {
			continue
		}
		if c[2][0]-b1 != c[2][1]-b2 || c[2][1]-b2 != c[2][2]-b3 {
			continue
		}
		ans = "Yes"
		break
	}

	fmt.Println(ans)

}


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()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	c := [4][4]int{}
	for i := 1; i <= 3; i++ {
		for j := 1; j <= 3; j++ {
			c[i][j] = getInt()
		}
	}
	ans := true
	if c[1][1]-c[1][2] != c[2][1]-c[2][2] {
		ans = false
	}
	// out(ans)
	if c[1][1]-c[1][2] != c[3][1]-c[3][2] {
		ans = false
	}
	// out(ans)

	if c[1][2]-c[1][3] != c[2][2]-c[2][3] {
		ans = false
	}
	// out(ans)
	if c[1][2]-c[1][3] != c[3][2]-c[3][3] {
		ans = false
	}
	// out(ans)

	if c[1][1]-c[2][1] != c[1][2]-c[2][2] {
		ans = false
	}
	// out(ans)
	if c[1][1]-c[2][1] != c[1][3]-c[2][3] {
		ans = false
	}
	// out(ans)

	if c[2][1]-c[3][1] != c[2][2]-c[3][2] {
		ans = false
	}
	// out(ans)
	if c[2][1]-c[3][1] != c[2][3]-c[3][3] {
		ans = false
	}
	// out(ans)

	if ans == true {
		out("Yes")
	} else {
		out("No")
	}
}


package main

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

func main() {
	c := make([][]int, 3)
	for i := range c {
		c[i] = append(c[i], readInt())
		c[i] = append(c[i], readInt())
		c[i] = append(c[i], readInt())
	}

	for b1 := 0; b1 <= 100; b1++ {
		a := []int{c[0][0] - b1, c[1][0] - b1, c[2][0] - b1}
		b := []int{b1, c[0][1] - a[0], c[0][2] - a[0]}
		// fmt.Println(a, b)

		ok := true
	label:
		for i := range c {
			for j := range c[i] {
				if c[i][j] != a[i]+b[j] {
					ok = false
					break label
				}
			}
		}
		if ok {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


package main

import "fmt"

func main() {
	grid := make([][]int, 3)

	for i := range grid {
		grid[i] = make([]int, 3)
		if i != 2 {
			fmt.Scanf("%d %d %d\n", &grid[i][0], &grid[i][1], &grid[i][2])
		} else {
			fmt.Scanf("%d %d %d", &grid[i][0], &grid[i][1], &grid[i][2])
		}
	}

	a := make([]int, 3)
	b := make([]int, 3)

	a[0] = 0
	b[0] = grid[0][0]
	b[1] = grid[1][0]
	b[2] = grid[2][0]
	a[1] = grid[0][1] - b[0]
	a[2] = grid[0][2] - b[0]

	flg := true
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if grid[i][j] == (a[j] + b[i]) {
				continue
			} else {
				flg = false
			}
		}
	}

	if flg {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


package main

import "fmt"

func main() {
	grid := make([][]int, 3)

	for i := range grid {
		grid[i] = make([]int, 3)
		fmt.Scanf("%d %d %d\n", &grid[i][0], &grid[i][1], &grid[i][2])
	}

	a := make([]int, 3)
	b := make([]int, 3)

	a[0] = 0
	b[0] = grid[0][0]
	b[1] = grid[1][0]
	b[2] = grid[2][0]
	a[1] = grid[0][1] - b[0]
	a[2] = grid[0][2] - b[0]

	flg := true
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if grid[i][j] == (a[j] + b[i]) {
				continue
			} else {
				flg = false
			}
		}
	}

	if flg {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


ary = []
3.times do |i|
    ary[i] = gets.split.map(&:to_i)
end
a1 = 0
b1 = ary[0][0] - a1
b2 = ary[0][1] - a1
b3 = ary[0][2] - a1
a2 = ary[1][0] - b1
a3 = ary[2][0] - b1
if (a1 + b1 == ary[0][0] &&
    a1 + b2 == ary[0][1] &&
    a1 + b3 == ary[0][2] &&
    a2 + b1 == ary[1][0] &&
    a2 + b2 == ary[1][1] &&
    a2 + b3 == ary[1][2] &&
    a3 + b1 == ary[2][0] &&
    a3 + b2 == ary[2][1] &&
    a3 + b3 == ary[2][2])
    puts 'Yes'
else
    puts 'No'
end


cs = 3.times.map{gets.chomp.split.map(&:to_i)}

a = [[0,0],[1,1],[2,2]].inject(0){|sum,(i,j)| sum += cs[i][j]}
b = [[0,2],[1,1],[2,0]].inject(0){|sum,(i,j)| sum += cs[i][j]}
c = [[0,0],[1,2],[2,1]].inject(0){|sum,(i,j)| sum += cs[i][j]}
d = [[0,1],[1,0],[2,2]].inject(0){|sum,(i,j)| sum += cs[i][j]}

puts [a,b,c,d].uniq.size == 1 ? "Yes" : "No"


c = readlines.map{|line| line.chomp.split.map(&:to_i)}
b = c[0].map{|i| i - c[0][0]}
a = (0..2).map{|j| c[j][0] - b[0]}
d = (0..2).map{|i| (0..2).map{|j| a[i] + b[j]}}

puts c == d ? :Yes : :No


c=[]
3.times do
  c << gets.split.map(&:to_i)
end
if c[0][1]-c[0][0]==c[1][1]-c[1][0]&&c[1][1]-c[1][0]==c[2][1]-c[2][0]||c[0][2]-c[0][1]==c[1][2]-c[1][1]&&c[1][2]-c[1][1]==c[2][2]-c[2][1]||c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][1]-c[0][1]==c[1][2]-c[0][2]||c[2][0]-c[1][0]==c[2][1]-c[1][1]&&c[2][1]-c[1][1]==c[2][2]-c[1][2]
  puts "Yes"
else
  puts "No"
end


ary = []
3.times do |i|
    ary[i] = gets.split.map(&:to_i)
end
max_n = ary.flatten.max
0.upto(max_n) do |a1|
    0.upto(max_n) do |b1|
        0.upto(max_n) do |a2|
            0.upto(max_n) do |b2|
                a3 = ary[2][0] - b1
                b3 = ary[0][2] - a1
                if (a1 + b1 == ary[0][0] &&
                    a1 + b2 == ary[0][1] &&
                    a1 + b3 == ary[0][2] &&
                    a2 + b1 == ary[1][0] &&
                    a2 + b2 == ary[1][1] &&
                    a2 + b3 == ary[1][2] &&
                    a3 + b1 == ary[2][0] &&
                    a3 + b2 == ary[2][1] &&
                    a3 + b3 == ary[2][2])
                    puts 'Yes'
                    exit
                end
            end
        end
    end
end
puts 'No'


ary = []
3.times do |i|
    ary[i] = gets.split.map(&:to_i)
end
max_n = ary.flatten.max
0.upto(max_n) do |a1|
    0.upto(max_n) do |a2|
        0.upto(max_n) do |a3|
            0.upto(max_n) do |b1|
                0.upto(max_n) do |b2|
                    0.upto(max_n) do |b3|
                        if (a1 + b1 == ary[0][0] &&
                            a1 + b2 == ary[0][1] &&
                            a1 + b3 == ary[0][2] &&
                            a2 + b1 == ary[1][0] &&
                            a2 + b2 == ary[1][1] &&
                            a2 + b3 == ary[1][2] &&
                            a3 + b1 == ary[2][0] &&
                            a3 + b2 == ary[2][1] &&
                            a3 + b3 == ary[2][2])
                            puts 'Yes'
                            exit
                        end
                    end
                end
            end
        end
    end
end
puts 'No'


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::collections::BinaryHeap;

fn main() {
    let mut map: Vec<Vec<i64>> = vec![vec![0; 3]; 3];

    for i in 0..3 {
        for j in 0..3 {
            map[i][j] = read();
        }
    }

    for a1 in 0..100 {
        let b1 = map[0][0] - a1;
        let b2 = map[0][1] - a1;
        let b3 = map[0][2] - a1;

        let a2 = map[1][0] - b1;
        let a3 = map[2][0] - b1;

        if b2 + a2 == map[1][1]
            && b3 + a2 == map[1][2]
            && b2 + a3 == map[2][1]
            && b3 + a3 == map[2][2]
        {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      c: [[i32; 3]; 3]
   }
   let b: Vec<_> = (0..3).map(|i| c[0][i]).collect();
   let a: Vec<_> = (0..3).map(|i| c[i][0] - b[0]).collect();
   for i in 0..3 {
      for j in 0..3 {
         if a[i] + b[j] != c[i][j] {
            println!("No");
            return;
         }
      }
   }
   println!("Yes");
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    c: [[usize; 3]; 3]
    }
    for i in  0..2{
        for j in 0..2{
            if c[i][j + 1] + c[i + 1][j] != c[i][j] + c[i + 1][j + 1]{
                println!("No");
                return
            }
        }
    }
    println!("Yes")
}


#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        Css: [[i64; 3]; 3],
    }

    let a0 = 0;
    for a1 in 0..=100 {
        for a2 in 0..=100 {
            let As = vec![a0, a1, a2];
            let Bs = vec![Css[0][0] - As[0], Css[0][1] - As[0], Css[0][2] - As[0]];

            let mut is_ok = true;
            for i in 0..3 {
                for j in 0..3 {
                    if Css[i][j] != As[i] + Bs[j] {
                        is_ok = false;
                    }
                }
            }

            if is_ok {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}


use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        c: [[usize; 3]; 3],
    }

    let mut tmp1 = 0;
    let mut tmp2 = 0;
    let mut tmp3 = 0;
    for i in 0..3 {
        for j in 0..3 {
            if i==0 {
                tmp1 += c[i][j];
            } else if i==1 {
                tmp2 += c[i][j];
            } else {
                tmp3 += c[i][j];
            }
        }
    }

    if (((tmp1 as i64) - (tmp2 as i64)).abs() % 3 == 0
    && ((tmp2 as i64) - (tmp3 as i64)).abs() % 3 == 0
    && ((tmp1 as i64) - (tmp3 as i64)).abs() % 3 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }

}


use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        c: [[usize; 3]; 3],
    }

    let mut tmp1 = 0;
    let mut tmp2 = 0;
    let mut tmp3 = 0;
    for i in 0..3 {
        for j in 0..3 {
            if i==0 {
                tmp1 += c[i][j];
            } else if i==1 {
                tmp2 += c[i][j];
            } else {
                tmp3 += c[i][j];
            }
        }
    }

    if (((tmp1 as i64) - (tmp2 as i64)).abs() % 3 == 0
    && ((tmp2 as i64) - (tmp3 as i64)).abs() % 3 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }

}


// 🐋💭
import Foundation

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

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }

    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {

    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt

    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2

        if Int(ary[mid])! < key {
            left = mid

        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }

    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    var tableC = [[Int]](repeating: [Int](repeating: 0, count: 3), count: 3)
    for i in 0..<3 {
        tableC[i] = readInts()
    }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var isMatch = true
    let diff = [tableC[0][0] - tableC[0][1], tableC[0][1] - tableC[0][2]]
    for i in 1..<3 {
        if tableC[i][0] - tableC[i][1] != diff[0] || tableC[i][1] - tableC[i][2] != diff[1] {
            isMatch = false
        }
    }
    print(isMatch ? "Yes": "No")
}
main()


// 🐋💭
import Foundation

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

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }

    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {

    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt

    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2

        if Int(ary[mid])! < key {
            left = mid

        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }

    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    var tableC = [[Int]](repeating: [Int](repeating: 100, count: 3), count: 3)
    var aryA = [Int](repeating: 100, count: 3)
    var aryB = [Int](repeating: 100, count: 3)
    for i in 0..<3 {
        tableC[i] = readInts()

    }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力

    for i in 0..<3 {
        for j in 0..<3 {
            aryA[i] = min(aryA[i], tableC[i][j])
            aryB[i] = min(aryB[i], tableC[j][i])
        }
    }

    for i in 0..<3 {
        for j in 0..<3 {
            if aryA[i] + aryB[j] != tableC[i][j] {
                print("No")
                return
            }
        }
    }
    print("Yes")
}
main()


import Foundation

let rdArr = [[Int]]()

let cRow1 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c11,c12,c13]をソート
let cRow2 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c21,c22,c31]
let cRow3 = readLine()!.split(separator: " ").map({Int($0)!})//.sorted(by: {$0>$1})//[c31,c32,c33]

var aRowS = [Int]()
var aRowT = [Int]()
var aRowU = [Int]()

// print(cRow1)
// print(cRow2)
// print(cRow3)

aRowS.append(abs(cRow1[0] - cRow1[1]))
aRowS.append(abs(cRow2[0] - cRow2[1]))
aRowS.append(abs(cRow3[0] - cRow3[1]))

aRowT.append(abs(cRow1[2] - cRow1[1]))
aRowT.append(abs(cRow2[2] - cRow2[1]))
aRowT.append(abs(cRow3[2] - cRow3[1]))

aRowU.append(abs(cRow1[2] - cRow1[0]))
aRowU.append(abs(cRow2[2] - cRow2[0]))
aRowU.append(abs(cRow3[2] - cRow3[0]))

// print(aRowS)
// print(aRowT)

if aRowS == aRowT || aRowS == aRowU || aRowT == aRowU {
    print("Yes")
} else {
    print("No")
}


function main(input) {
  input = input.trim().split("\n");
  const c = input.map(s => s.split(" ").map(t => Number(t)));
  let result = "No";
  const a1 = 0;
  const b1 = c[0][0] - a1;
  const a2 = c[1][0] - b1;
  const a3 = c[2][0] - b1;
  const b2 = c[0][1] - a1;
  const b3 = c[0][2] - a1;
  if (c[1][1] === a2 + b2 && c[1][2] === a2 + b3 && c[2][1] === a3 + b2 && c[2][2] === a3 + b3) {
    result = "Yes";
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


const log = console.log;

const flatNaive = <T>(arrays: T[][]): T[] => [].concat.apply([], arrays);

// ----

function Main(input: string): void {
  const c = input
    .trim()
    .split("\n")
    .map(s => s.split(" ").map(s => parseInt(s)));

  const flatC = flatNaive(c);
  const minC = Math.min(...flatC);
  const maxC = Math.max(...flatC);

  for (let a0 = minC; a0 <= maxC; a0++) {
    // If we know a[0], other values should also be determined
    const b = [c[0][0] - a0, c[0][1] - a0, c[0][2] - a0];
    const a = [a0, c[1][0] - b[0], c[2][0] - b[0]];

    // Validate excluding a[0]
    let valid = true;

    for (let i = 1; i < 3; i++) {
      for (let j = 0; j < 3; j++) {
        if (c[i][j] !== a[i] + b[j]) {
          valid = false;
          break;
        }
      }

      if (!valid) break;
    }

    if (valid) {
      log("Yes");

      return;
    }
  }

  log("No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  input = input.trim().split("\n");
  const c = input.map(s => s.split(" ").map(t => Number(t)));
  let result = "No";
  for (let i = 0; i <= c[0][0]; i++) {
    const a1 = i;
    const b1 = c[0][0] - a1;
    const a2 = c[1][0] - b1;
    const a3 = c[2][0] - b1;
    const b2 = c[0][1] - a1;
    const b3 = c[2][0] - a1;
    if (c[1][1] === a2 + b2 && c[1][2] === a2 + b3 && c[2][1] === a3 + b2 && c[2][2] === a3 + b3) {
      result = "Yes";
      break;
    }
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


print(input().replace('2017', '2018'))


print( input().replace('2017','2018'))


n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for j in range(y // 5000 + 1):
        k = n - i - j
        if 0 <= k and 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k,sep=" ")
            exit()
print("-1 " + "-1" + " -1")


import sys

S = sys.stdin.readline().strip()
print("2018" + S[5:])


s = list(input())
s[3] = "8"
print(s)


import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		char[] str = in.readLine().toCharArray();
		str[3] = '8';
		String s = new String(str);
		System.out.println(s);
	}
}


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        s[3] = '8';
        System.out.println(new String(s));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(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;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String dateString = br.readLine();
            String convertTo2018 = "2018" + dateString.substring(4, 10);

            System.out.println(convertTo2018);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}


import java.util.*;

public class Main{

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

      List<Integer> split = new ArrayList<>();
        for (int i = 0; i < n; i++) {
	        int buf = sc.nextInt();
	        split.add(buf);
        }

        int tmp = 0;
        int tmp2 = 0;
        int size = split.size();

        for(int i = 0; i < size ; i++ ){
            tmp = split.get(i);

            for(int j = 0; j < size ; j++){
                tmp2 = split.get(j);

                if(tmp2 == tmp && j!= i){
                  split.remove(j);
                  size -= 1;
                  j--;
                }
            }
        }
    if(size == 1){size = 0;}
    System.out.println(size);
  }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replace("7", "8");
        System.out.println(s);
    }
}


import java.util.Scanner;
public class Main {
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();

    ss[3] = '7';
    	 System.out.println(String.valueOf(ss));
    }
}


#include<stdio.h>

int main(){

	char s[100];

	scanf("%s",s);

	s[3]='8';

	printf("%s",s);

	return 0;
}


#include<stdio.h>
int main()
{
    char str[10];
    int i;
    for(i=0;i<=9;i++)
    {
        scanf("%c",&str[i]);
    }
    str[3]='8';
    printf("%s",str);
    return 0;
}


#include<stdio.h>
int main()
{
char s[15]={0};
scanf("%s",s);
s[3]='8';
printf("%s",s);
return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	string s;
	cin >> s;
	s.replace(4, 1, "8");
	cout << s << "\n";
}


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

int main() {
  string s;
  cin >> s;
  s[3]=8;
  cout << s << endl;

}


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

int main() {
  string s;
  cin >> s;
  s[3]==8;
  cout << s << endl;

}


#include <stdio.h>
int main(void){
    int i;
    char s[10];
    scanf("%s",s);
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    printf("%s\n",s);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    char S[12],i;
    scanf(" %[^\n]",S);
    for(i=0;i<strlen(S);i++){
        S[0]='2';
        S[1]='0';
        S[2]='1';
        S[3]='8';
    }
    printf("%s",S);

    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    char string[11];
    scanf("%s",string);
    char modified[11];
    modified[0]='2';
    modified[1]='0';
    modified[2]='1';
    modified[3]='8';
    int i;
    for(i=4;i<strlen(string);i++)
    {
        modified[i]=string[i];
    }
    modified[i]='\0';
    printf("%s\n",modified);
    return 0;
}


#include<stdio.h>
int main(){
  char a;
  scanf("%s", &a);

  a[3]="8";

  printf("%s", a);

  return 0;
}


#include<stdio.h>
int main(){
  char a;
  scanf("%s", &a);
  for(int i=0;i<10;i++){
    a[i]=a[i];
    if(i==3)
      a[i]="8";
  }

  for(int i=0;i<10;i++){
    printf("%s", a[i]);
  }
  return 0;
}


#include<stdio.h>
int main(){
  char a[10];
  scanf("%s", &a);
  for(int i=0;i<10;i++){
    a[i]=a[i];
    if(i==3)
      a[i]=="8";
  }

  for(int i=0;i<10;i++){
    printf("%s", a[i]);
  }
  return 0;
}


function main(input) {
  var result = input.replace('2017', '2018');
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input) {
  console.log(`2018/${input.slice(5)}`);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict'

const main = input => {
	console.log(input.replace('2017', '2018'))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


function main(input) {
	const args = input.split('\n');
  	const N = parseInt(args[0], 10);
  	let arr = args.slice(1, args.length).map((n) => parseInt(n, 10));

  	const another_arr = [...new Set(arr)];

  	console.log(parseInt(another_arr.length, 10));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const stdin=require("fs").readFileSync("/dev/stdin", "utf8");
const argv=stdin.split("\n");
//const total=Number(argv[0]);
const mochies=argv.slice(1);

//重複しないもちぃのみを抜き出す
const uniqMochies=mochies.filter((a,idx,self)=>self.indexOf(a)==idx);

console.log(uniqMochies.length);


function main(input) {
  input = input.trim();
  const a = input.split("").map(Number);
  a[3]=8;
  console.log(a);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Printf("%s%s%s", s[0:3], "8", s[4:])
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	fmt.Println(strings.Replace(s,"7","8",1))
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	r := strings.Replace(s, "2017", "2018", 1)
	fmt.Println(r)
}


package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j <= N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)

	for i := 0; i < N; i++ {
		for j := 0; j < N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	fmt.Println(calcMoney(n, y))
}

func calcMoney(n int, yen int) (str string) {
	for x := 0; x <= n; x++ {
		for y := 0; y <= n; y++ {
			z := n - x - y
			if 0 <= z && yen == 10000*x+5000*y+1000*z {
				return fmt.Sprintf("%d %d %d", x, y, z)
			}
		}
	}
	return "-1 -1 -1"
}


puts gets.chomp.gsub("2017", "2018")


day = gets.chomp.gsub(/2017/,'2018')
puts day


st = gets.chomp.split("/")

st[0] = "2018"

print st[0]
print "/"
print st[1]
print "/"
puts st[2]


n = gets.to_i
mochis = n.times.map { gets.to_i }
puts mochis.uniq.size


arr = gets.strip.split.map(&:to_i).uniq

puts arr.length


s=gets.chomp;puts s.gsub(s[3],"8")


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 s = get!(String).chars().collect::<Vec<_>>();
    s[3] = '8';
    println!("{}", s.into_iter().collect::<String>());
}


#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

fn type_of<T>(_: T) -> String{
    let a = std::any::type_name::<T>();
    return a.to_string();
}

#[fastout]
fn main() {
    input! {
        mut s:Chars,
    }
    s[3]='8';
    println!("{}",s.iter().collect::<String>());
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    s: chars,
    }
    let mut y = "2018".chars().collect::<Vec<char>>();
    y.extend_from_slice(&s[4..]);
    for i in y {
        print!("{}", i);
    }
}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    };
    let mut ss = s.clone();
    ss[3] = '8';
    println!("{}", ss.iter().collect::<String>())
}


#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();
    let ans = s.replacen("7", "8", 1);
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();
    let ans = s.replace("7", "8");
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


import Glibc
extension String: CollectionType {}

//var inp = readLine()!.split(" ").map { Int($0)! }
var s = readLine()!.split("/")
print("2018/"+s[1]+"/"+s[2])


print("2018/01/"+readLine()!.characters.split("/").map{String($0)}[2])


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

let ints = readInts()
let n = ints[0]
let sum = ints[1]

func main() {
    for i in 0...n {
        for j in 0...(n - i) {
            for k in 0...(n - i - j) {
                if i * 10_000 + j * 5_000 + k * 1_000 == sum && i + j + k == n {
                    print("\(i) \(j) \(k)")
                    return
                }
            }
        }
    }
    print("-1 -1 -1")
}

main()


print("2018/01/"+readLine()!.characters.split("/").map{String($0)}[3])


Gshshshzgsgsgshshshdhdhdhdhdhdhxhxbvvxvxvsgsusudhxbxbxbxbxbxhdhdjdjdhxhxhhdhdhxhxhdhhsshsbdhjxhdhdhdhdhdhd


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

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

const res = s.replace('2017', '2018')

console.log(res)


import * as fs from 'fs';

namespace AtCoder.abc086 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program): void {
            const [s]: string[] = this.args[0];
            console.log (s.replace('2017', '2018'));

        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc086.Program = new AtCoder.abc086.Program(args);
prg.main();


const log = console.log;

const replaceStringAt = (
  str: string,
  index: number,
  length: number,
  replaceValue: string
) => str.substr(0, index) + replaceValue + str.substr(index + length);

// ----

function Main(input: string): void {
  log(replaceStringAt(input, 3, 1, "8"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


import * as fs from 'fs';

namespace AtCoder.abc086 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program): void {
            const [s]: string[] = this.args[0];
            s.replace('2017','2018');
        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc086.Program = new AtCoder.abc086.Program(args);
prg.main();


n,m=map(int,input().split())
print(max(-1,n-sum(list(map(int,input().split())))))


N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
if N - sum(A) >= 0:
     print(N - sum(A))
else:
    print(-1)


# coding: utf-8
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

sum = sum(A)
print(max([N-sum, -1]))


N, M = map(int, input().split())
A = list(map(int, input().split()))
assert len(A) == M
# M個の宿題, それぞれAi日かかる
yasumi = N - sum(A)
if yasumi > 0:
  print(yasumi)
else:
  print(-1)


def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

def main(n,m,a):
    days=sum(a)
    if days<n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)


N, M = map(int, input().split())
A = list(map(int, input().split()))

if N - sum(A) > 0:
    print(N-sum(A))
else:
    print(-1)


import java.io.*;
import java.util.*;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";

	static final long mod = (long) 1e9 + 7;
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int inf = Integer.MAX_VALUE / 3;
	static final long linf = Long.MAX_VALUE / 3;
	static final double dinf = Double.MAX_VALUE / 3;

	static void solve() {
		int n = ni(), m = ni();
		long t = 0;
		for(int i=0;i<m;i++) {
			t += ni();
		}
		long ans = n - t;
		if(ans<0)out.println(-1);
		else out.println(ans);
	}

	//libraries
	/**
	*	upperBound
	*	@param List<T> 探索対象のList
	*   @param T 探索値
	*	@return xよりも大きい要素のうち、indexが最小の物のindex
	*/
	static <T> int upperBound(List<T> ls, T x) throws RuntimeException {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	lowerBound
	*	@param List<T> 探索対象のList
	*   @param T 探索値
	*	@return x以上の要素のうち、indexが最小の物のindex
	*/
	static <T> int lowerBound(List<T> ls, T x) {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rupperBound
	 *  @memo 降順ソートされたListに対して利用する
	 *	@param List<T> 探索対象のList
	 *  @param T 探索値
	 *	@return xよりも大きい要素のうち、indexが最小の物のindex
	 */
	static <T> int rupperBound(List<T> ls, T x) throws RuntimeException {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rlowerBound
	 *  @memo 降順ソートされたListに対して利用する
	 *	@param List<T> 探索対象のList
	 *  @param T 探索値
	 *	@return x以上の要素のうち、indexが最小の物のindex
	 */
	static <T> int rlowerBound(List<T> ls, T x) {
		if (ls.size() == 0)
			return -1;
		if (ls.get(0) instanceof Integer) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Long) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);
		} else if (ls.get(0) instanceof Double) {
			return ~Collections.binarySearch(ls, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でないリストを二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	upperBound
	*	@param T[] 探索対象の配列
	*   @param T 探索値
	*	@return xよりも大きい要素のうち、indexが最小の物のindex
	*/
	static <T> int upperBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) > 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) > 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) > 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	*	lowerBound
	*	@param T[] 探索対象の配列
	*   @param T 探索値
	*	@return x以上の要素のうち、indexが最小の物のindex
	*/
	static <T> int lowerBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) >= 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) >= 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) >= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rupperBound
	 *  @memo 降順ソートされた配列に対して利用する
	 *	@param T[] 探索対象の配列
	 *  @param T 探索値
	 *	@return xよりも大きい要素のうち、indexが最小の物のindex
	 */
	static <T> int rupperBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) < 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) < 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) < 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	/**
	 *	rlowerBound
	 *  @memo 降順ソートされた配列に対して利用する
	 *	@param T[] 探索対象の配列
	 *  @param T 探索値
	 *	@return x以上の要素のうち、indexが最小の物のindex
	 */
	static <T> int rlowerBound(T[] ar, T x) {
		if (ar instanceof Integer[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Integer) t1).compareTo((Integer) t2) <= 0 ? 1 : -1);
		} else if (ar instanceof Long[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Long) t1).compareTo((Long) t2) <= 0 ? 1 : -1);
		} else if (ar instanceof Double[]) {
			return ~Arrays.binarySearch(ar, x, (t1, t2) -> ((Double) t1).compareTo((Double) t2) <= 0 ? 1 : -1);
		} else {
			System.err.println(
					String.format("%s:数値でない配列を二分探索しています。", Thread.currentThread().getStackTrace()[1].getMethodName()));
			throw new RuntimeException();
		}
	}

	static int[] concat(int x, int arr[]) {
		int ret[] = new int[arr.length + 1];
		System.arraycopy(arr, 0, ret, 1, ret.length - 1);
		ret[0] = x;
		return ret;
	}

	static int[] concat(int arr[], int x) {
		int ret[] = new int[arr.length + 1];
		System.arraycopy(arr, 0, ret, 0, ret.length - 1);
		ret[ret.length - 1] = x;
		return ret;
	}

	static long[] concat(long x, long arr[]) {
		long ret[] = new long[arr.length + 1];
		System.arraycopy(arr, 0, ret, 1, ret.length - 1);
		ret[0] = x;
		return ret;
	}

	static long[] concat(long arr[], long x) {
		long ret[] = new long[arr.length + 1];
		System.arraycopy(arr, 0, ret, 0, ret.length - 1);
		ret[ret.length - 1] = x;
		return ret;
	}

	static long max(long x, long y) {
		return Math.max(x, y);
	}

	static long min(long x, long y) {
		return Math.min(x, y);
	}

	static long max(long x, long y, long z) {
		x = Math.max(x, y);
		x = Math.max(x, z);
		return x;
	}

	static long min(long x, long y, long z) {
		x = Math.min(x, y);
		x = Math.min(x, z);
		return x;
	}

	static double max(double x, double y) {
		return Math.max(x, y);
	}

	static double min(double x, double y) {
		return Math.min(x, y);
	}

	static double max(double x, double y, double z) {
		x = Math.max(x, y);
		x = Math.max(x, z);
		return x;
	}

	static double min(double x, double y, double z) {
		x = Math.min(x, y);
		x = Math.min(x, z);
		return x;
	}

	static void sort(int[] ar) {
		Arrays.sort(ar);
	}

	static void sort(long[] ar) {
		Arrays.sort(ar);
	}

	static void sort(double[] ar) {
		Arrays.sort(ar);
	}

	static void rsort(int[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			int tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(long[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			long tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(double[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			double tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void fill(int arr[], int x) {
		Arrays.fill(arr, x);
	}

	static void fill(long arr[], long x) {
		Arrays.fill(arr, x);
	}

	static void fill(double arr[], double x) {
		Arrays.fill(arr, x);
	}

	static void fill(int arr[][], int x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	static void fill(long arr[][], long x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	static void fill(double arr[][], double x) {
		for (int i = 0; i < arr.length; i++)
			Arrays.fill(arr[i], x);
	}

	//MOD culc
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}

	public static void main(String[] args) throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	//input
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;

	private static int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private static boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private static int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	@SuppressWarnings("unused")
	private static double nd() {
		return Double.parseDouble(ns());
	}

	@SuppressWarnings("unused")
	private static char nc() {
		return (char) skip();
	}

	private static String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private static char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	@SuppressWarnings("unused")
	private static char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	@SuppressWarnings("unused")
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	@SuppressWarnings("unused")
	private static long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            for (int i = 0; i < m; i++) {
                n -= in.nextInt();
            }

            out.println(0 <= n ? n : -1);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            for (int i = 0; i < m; i++) {
                n -= in.nextInt();
            }

            out.println(0 <= n ? n : -1);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}


import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int ans = 0:
    for (int i = 0; i < m; i++){
      ans = ans + scan.nextInt();
    }
    if (ans <=n){
      System.out.println(n - ans);
    }else{
      System.out.println(-1);
    }
  }
}


import java.util.Scanner;
public class Main {

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

		for(int i=0;i<m;i++) {
			a[i] = scan.nextInt();
			count += a[i];
		}

		if(n > count) {
			System.out.println(n-count);
		}else {
			System.out.println(-1);
		}

	}

}