#import <Foundation/Foundation.h>
#import <stdlib.h>
#import <stdarg.h>
typedef NSInteger Int;
typedef NSUInteger UINT;
@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn;
+(NSMutableArray*)stringsFromStdInSeparatedByString:(NSString*)separator;
+(NSMutableArray*)stringsFromStdInSeparatedByCharacter:(unichar)separator;
+(NSMutableArray*)numbersFromStdInSeparatedByString:(NSString*)separator;
+(NSMutableArray*)numbersFromStdInSeparatedByCharacter:(unichar)separator;
+(void)put:(char*)format, ...;
+(void)puts:(NSString*)format, ...;
@end
@interface NSString (Extension)
-(NSMutableArray*)componentsSeparatedByCharacter:(unichar)separator;
-(NSMutableArray*)numbersSeparatedByString:(NSString*)separator;
-(NSMutableArray*)numbersSeparatedByCharacter:(unichar)separator;
-(NSMutableArray*)splitCharacterEvery:(UINT)number;
-(NSMutableArray*)characterStrings; // 1文字ずつの NSString* の配列を返す
-(NSMutableArray*)characters; // 1文字ずつの unichar をラップした NSNumber の配列を返す
-(unichar)firstCharacter;
-(unichar)lastCharacter;
-(NSString*)leadingSubstringWithLength:(UINT)length;
-(NSString*)trailingSubstringWithLength:(UINT)length;
@end
@interface NSMutableArray (Extension)
+(NSMutableArray*)arrayWithNumbers:(Int)count, ...; // 要素数, 数1, 数2, ... から NSMutableArray<NSNumber*> オブジェクトを生成
-(NSMutableArray*)unshift:(id)element;
-(id)shift;
-(NSMutableArray*)push:(id)element;
-(id)pop;
@end
@interface NSMutableString (Extension)
-(NSMutableString*)unshift:(NSString*)string;
-(NSString*)shiftWithLength:(UINT)length;
-(NSMutableString*)push:(NSString*)string;
-(NSString*)popWithLength:(UINT)length;
@end
@interface NSArray (Extension)
-(Int)integerValueAtIndex:(UINT)index;
-(Int)firstInteger;
-(Int)secondInteger;
-(Int)thirdInteger;
-(Int)fourthInteger;
-(NSMutableArray*)sortedArrayWithAscending:(BOOL)ascending; // NSNumber* を要素に持つ配列をソート
-(NSMutableArray*)unique;
@end
@interface Matrix : NSObject
{
		Int _width;
		Int _height;
		NSMutableArray *_rows;
}
-(instancetype)initWithRows:(NSArray*)rows;
-(Matrix*)copy;
-(double)valueAtRow:(UINT)row column:(UINT)column;
-(void)setValue:(double)value atRow:(UINT)row column:(UINT)column;
-(void)exchangeRowAt:(UINT)i withRowAt:(UINT)j;
-(Int)rank;
-(NSString*)description;
@end
@implementation Matrix
-(instancetype)initWithRows:(NSArray*)rows
{
		if (self = [super init]) {
				_rows = [NSMutableArray array];
				for (NSArray *row in rows) {
						[_rows push: [NSMutableArray arrayWithArray: row]];
				}
				_height = [rows count];
				_width = [(NSArray*)[rows objectAtIndex:0] count];
		}
		return self;
}
-(Matrix*)copy
{
		return [[Matrix alloc] initWithRows: _rows];
}
-(double)valueAtRow:(UINT)row column:(UINT)column
{
		return [(NSNumber*)[(NSArray*)[_rows objectAtIndex: row] objectAtIndex: column] doubleValue];
}
-(void)setValue:(double)value atRow:(UINT)row column:(UINT)column
{
		NSMutableArray *rowArray = (NSMutableArray*)[_rows objectAtIndex: row];
		[rowArray replaceObjectAtIndex:column withObject: @(value)];
		[_rows replaceObjectAtIndex:row withObject:rowArray];
}
-(void)exchangeRowAt:(UINT)i withRowAt:(UINT)j
{
		[_rows exchangeObjectAtIndex:i withObjectAtIndex:j];
}
-(Int)rank
{
		Matrix *mat = [self copy];
		Int rank = _width;
		for (Int row = 0; row < rank; row++) {
				// Before we visit current row 'row', we make
				// sure that mat[row][0],....mat[row][row-1]
				// are 0.
				// Diagonal element is not zero
				if ([mat valueAtRow:row column:row] != 0) {
						for (int col = 0; col < _height; col++) {
								if (col != row) {
										// This makes all entries of current
										// column as 0 except entry 'mat[row][row]'
										double mult = [mat valueAtRow:col column:row] / [mat valueAtRow:row column:row];
										for (int i = 0; i < rank; i++) {
												double a = mult * [mat valueAtRow:row column:i];
												double b = [mat valueAtRow:col column:i];
												[mat setValue:b-a atRow:col column:i];
										}
								}
						}
				}
				// Diagonal element is already zero. Two cases
				// arise:
				// 1) If there is a row below it with non-zero
				//    entry, then swap this row with that row
				//    and process that row
				// 2) If all elements in current column below
				//    mat[r][row] are 0, then remvoe this column
				//    by swapping it with last column and
				//    reducing number of columns by 1.
				else {
						BOOL reduce = YES;
						// Find the non-zero element in current column
						for (Int i = row+1; i < _height;  i++) {
								// Swap the row with non-zero element
								// with this row.
								if ([mat valueAtRow:i column:row] != 0) {
										[mat exchangeRowAt:row withRowAt:i];
										reduce = NO;
										break ;
								}
						}
						// If we did not find any row with non-zero
						// element in current columnm, then all
						// values in this column are 0.
						if (reduce) {
								// Reduce number of columns
								rank--;
								// Copy the last column here
								for (Int i = 0; i < _height; i ++) {
										double a = [mat valueAtRow:i column:rank];
										[mat setValue:a atRow:i column:row];
								}
						}
						// Process this row again
						row--;
				}
				// Uncomment these lines to see intermediate results
				// display(mat, R, C);
				// printf("\n");
		}
		return rank;
}
-(NSString*)description
{
		NSMutableString *result = [NSMutableString string];
		for (UINT i=0; i<_height; i++) {
				NSMutableArray *line = [NSMutableArray array];
				for (UINT j=0; j<_width; j++) {
						Int value = [self valueAtRow:i column:j];
						[line push: @(value)];
				}
				[result push: [line componentsJoinedByString:@", "]];
				[result push: @"\n"];
		}
		return result;
}
@end
@implementation NSArray (Extension)
-(Int)integerValueAtIndex:(UINT)index
{
		return [[self objectAtIndex:index] integerValue];
}
-(Int)firstInteger
{
		return [self integerValueAtIndex: 0];
}
-(Int)secondInteger
{
		return [self integerValueAtIndex: 1];
}
-(Int)thirdInteger
{
		return [self integerValueAtIndex: 2];
}
-(Int)fourthInteger
{
		return [self integerValueAtIndex: 3];
}
-(NSMutableArray*)sortedArrayWithAscending:(BOOL)ascending
{
		NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey: @"self" ascending: ascending];
		NSArray *descriptors = [NSArray arrayWithObject: descriptor];
		NSArray *sortedArray = [self sortedArrayUsingDescriptors: descriptors];
		return [NSMutableArray arrayWithArray: sortedArray];
}
-(NSMutableArray*)unique
{
		NSMutableArray *result = [NSMutableArray array];
		NSEnumerator *enumerator = [self objectEnumerator];
		id object;
		while ((object = [enumerator nextObject])) {
				if (![result containsObject: object]) {
						[result push: object];
				}
		}
		return result;
}
@end
@implementation NSMutableString (Extension)
-(NSMutableString*)unshift:(NSString*)string
{
		[self insertString: string atIndex: 0];
		return self;
}
-(NSString*)shiftWithLength:(UINT)length
{
		if ([self length] >= length) {
				NSRange range = NSMakeRange(0, length);
				NSString *first = [self substringWithRange: range];
				[self deleteCharactersInRange: range];
				return first;
		} else {
				return nil;
		}
}
-(NSString*)push:(NSString*)string
{
		[self appendString: string];
		return self;
}
-(NSString*)popWithLength:(UINT)length
{
		UINT mylength = [self length];
		if (length <= mylength) {
				NSRange range = NSMakeRange(mylength - length, length);
				NSString *last = [self substringWithRange: range];
				[self deleteCharactersInRange: range];
				return last;
		} else {
				return nil;
		}
}
@end
@implementation NSMutableArray (Extension)
+(NSMutableArray*)arrayWithNumbers:(Int)count, ...
{
		va_list numbers;
		va_start(numbers, count);
		NSMutableArray *array = [NSMutableArray array];
		for (Int i = 0; i < count; i++) {
				[array push: [NSNumber numberWithInt:va_arg(numbers, int)]];
		}
		va_end(numbers);
		return array;
}
-(NSMutableArray*)unshift:(id)element
{
		[self insertObject: element atIndex: 0];
		return self;
}
-(id)shift
{
		if ([self count] > 0) {
				id first = [self objectAtIndex: 0];
				[self removeObjectAtIndex: 0];
				return first;
		} else {
				return nil;
		}
}
-(NSMutableArray*)push:(id)element
{
		[self addObject: element];
		return self;
}
-(id)pop
{
		UINT count = [self count];
		if (count > 0) {
				id last = [self objectAtIndex: count - 1];
				[self removeLastObject];
				return last;
		} else {
				return nil;
		}
}
@end
@implementation NSString (Extension)
-(NSMutableArray*)componentsSeparatedByCharacter:(unichar)separator
{
		return [NSMutableArray arrayWithArray: [self componentsSeparatedByString:[NSString stringWithFormat:@"%c", separator]]];
}
-(NSMutableArray*)numbersSeparatedByString:(NSString*)separator
{
		NSArray *strings = [self componentsSeparatedByString: separator];
		NSMutableArray *numbers = [NSMutableArray array];
		for (NSString *string in strings) {
				if (![string isEqualToString:@""]) {
						[numbers addObject: [NSNumber numberWithInteger: [string integerValue]]];
				}
		}
		return numbers;
}
-(NSMutableArray*)numbersSeparatedByCharacter:(unichar)separator
{
		return [self numbersSeparatedByString:[NSString stringWithFormat:@"%c", separator]];
}
-(NSMutableArray*)splitCharacterEvery:(UINT)number
{
		if ([self length] <= number) {
				return [NSMutableArray arrayWithObject: self];
		}
		NSMutableArray  *mArray = [NSMutableArray array];
		NSMutableString *mStr   = [NSMutableString stringWithString: self];
		NSRange range = NSMakeRange(0, number);
		while ([mStr length] > 0) {
				if ([mStr length] < number) {
						[mArray addObject: [NSString stringWithString: mStr]];
						[mStr deleteCharactersInRange:NSMakeRange(0, [mStr length])];
				} else {
						[mArray addObject: [mStr substringWithRange: range]];
						[mStr deleteCharactersInRange: range];
				}
		}
		return mArray;
}
-(NSMutableArray*)characterStrings {
		return [self splitCharacterEvery: 1];
}
-(NSMutableArray*)characters {
		NSMutableArray *result = [NSMutableArray array];
		for (UINT i=0; i<[self length]; i++) {
				[result push: @([self characterAtIndex: i])];
		}
		return result;
}
-(unichar)firstCharacter
{
		return [self characterAtIndex: 0];
}
-(unichar)lastCharacter
{
		return [self characterAtIndex: [self length] - 1];
}
-(NSString*)leadingSubstringWithLength:(UINT)length
{
		if (length <= [self length]) {
				return [self substringWithRange: NSMakeRange(0, length)];
		} else {
				return nil;
		}
}
-(NSString*)trailingSubstringWithLength:(UINT)length
{
		UINT mylength = [self length];
		if (length <= mylength) {
				return [self substringWithRange: NSMakeRange(mylength - length, length)];
		} else {
				return nil;
		}
}
@end
@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
		NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
		NSMutableString *result = [NSMutableString string];
		NSData *data = [handle availableData];
		while ([data length] > 0) {
				[result appendString:[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]];
				data = [handle availableData];
		}
		if ([result lastCharacter] == '\n') {
				[result popWithLength: 1];
		}
		return result;
}
+(NSMutableArray*)stringsFromStdInSeparatedByString:(NSString*)separator
{
		return [NSMutableArray arrayWithArray: [[StdIO stringFromStdIn] componentsSeparatedByString: separator]];
}
+(NSMutableArray*)stringsFromStdInSeparatedByCharacter:(unichar)separator
{
		return [NSMutableArray arrayWithArray: [[StdIO stringFromStdIn] componentsSeparatedByCharacter: separator]];
}
+(NSMutableArray*)numbersFromStdInSeparatedByString:(NSString*)separator
{
		return [[StdIO stringFromStdIn] numbersSeparatedByString: separator];
}
+(NSMutableArray*)numbersFromStdInSeparatedByCharacter:(unichar)separator
{
		return [[StdIO stringFromStdIn] numbersSeparatedByCharacter: separator];
}
+(void)putsToStdOut:(NSString*)string
{
		NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
		[fileHandle writeData:[string dataUsingEncoding: NSUTF8StringEncoding]];
		[fileHandle writeData:[@"\n" dataUsingEncoding: NSUTF8StringEncoding]];
}
+(void)put:(char*)format, ...
{
		va_list arguments;
		va_start(arguments, format);
		NSString *string = [[NSString alloc] initWithFormat: [NSString stringWithUTF8String: format] arguments: arguments];
		[StdIO putsToStdOut: string];
		va_end(arguments);
}
+(void)puts:(NSString*)format, ...
{
		va_list arguments;
		va_start(arguments, format);
		NSString *string = [[NSString alloc] initWithFormat: format arguments: arguments];
		[StdIO putsToStdOut: string];
		va_end(arguments);
}
@end
int main(int argc, const char * argv[]) {
		@autoreleasepool {
				NSArray *lines = [StdIO stringsFromStdInSeparatedByCharacter:'\n'];
				NSArray *firstLine = [(NSString*)[lines objectAtIndex: 0] numbersSeparatedByCharacter:' '];
				NSArray *secondLine = [(NSString*)[lines objectAtIndex: 1] numbersSeparatedByCharacter:' '];
				NSArray *thirdLine = [(NSString*)[lines objectAtIndex: 2] numbersSeparatedByCharacter:' '];
				Int c[3][3] = {};
				c[0][0] = [firstLine firstInteger];
				c[0][1] = [firstLine secondInteger];
				c[0][2] = [firstLine thirdInteger];
				c[1][0] = [secondLine firstInteger];
				c[1][1] = [secondLine secondInteger];
				c[1][2] = [secondLine thirdInteger];
				c[2][0] = [thirdLine firstInteger];
				c[2][1] = [thirdLine secondInteger];
				c[2][2] = [thirdLine thirdInteger];
				NSArray *rows = @[@[@(1),@(0),@(0),@(1),@(0),@(0),@(c[0][0])],
													@[@(1),@(0),@(0),@(0),@(1),@(0),@(c[0][1])],
													@[@(1),@(0),@(0),@(0),@(0),@(1),@(c[0][2])],
													@[@(0),@(1),@(0),@(1),@(0),@(0),@(c[1][0])],
													@[@(0),@(1),@(0),@(0),@(1),@(0),@(c[1][1])],
													@[@(0),@(1),@(0),@(0),@(0),@(1),@(c[1][2])],
													@[@(0),@(0),@(1),@(1),@(0),@(0),@(c[2][0])],
													@[@(0),@(0),@(1),@(0),@(1),@(0),@(c[2][1])],
													@[@(0),@(0),@(1),@(0),@(0),@(1),@(c[2][2])],
													 ];
				Matrix *mat = [[Matrix alloc] initWithRows: rows];
				Int rank = [mat rank];
				[StdIO put: (rank > 5) ? "No" : "Yes"];
		}
		return 0;
}


Measured memory_bytes: 4388