//! Ported case for case from `packages/core/__tests__/qr/encode.test.ts`.//!//! The last block is the one that matters most: `fixtures/*.txt` there were//! produced once by `qrcode@1.5.4`, an encoder nobody in this tree wrote, and a//! level-M fixture has to match module for module with the MASK CHOICE//! included. That is the assertion no amount of re-reading the standard//! replaces — the four penalty rules are where two conforming encoders are//! allowed to differ, and a symbol that agrees with an independent encoder on//! all four is a symbol a reader will decode.//!//! The grids are held here as literals rather than read from the TypeScript//! package's directory: that package is being retired, and a guard that reads//! another package's file BY PATH goes quiet rather than red when the file//! moves. The L/Q/H fixtures are not carried over — this encoder is level M//! only, and the TypeScript suite lists them as `it.todo` for the same reason.usesuper::*;const FINDER: [[u8; 7]; 7] = [ [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1],];const ALIGNMENT_PATTERN: [[u8; 5]; 5] = [ [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1],];fn pattern_at(m: &[Vec<bool>], r0: usize, c0: usize, pattern: &[&[u8]]) -> bool {for (r, row) in pattern.iter().enumerate() {for (c, &cell) in row.iter().enumerate() {if m[r0 + r][c0 + c] != (cell == 1) {returnfalse; } } }true}fn finder_at(m: &[Vec<bool>], r0: usize, c0: usize) -> bool {let rows: Vec<&[u8]> = FINDER.iter().map(|row| &row[..]).collect(); pattern_at(m, r0, c0, &rows)}fn alignment_at(m: &[Vec<bool>], r0: usize, c0: usize) -> bool {let rows: Vec<&[u8]> = ALIGNMENT_PATTERN.iter().map(|row| &row[..]).collect(); pattern_at(m, r0, c0, &rows)}/// Bytes of a payload, counted the way the encoder counts them (UTF-8).fn byte_length(text: &str) -> usize { text.len()}fn encoded(text: &str) -> QrMatrix { encode_qr(text).expect("encode_qr should not refuse this payload")}/// Read back one of the two copies of the 15-bit format information, undoing/// the 0x5412 mask. Bit i of the returned value is the module the standard/// places at that position, so a caller can check the BCH(15,5) remainder and/// the fields.fn read_format(m: &QrMatrix, copy: u8) -> u32 {let size = m.size;let modules = &m.modules;letmut bits = 0u32;letmut put = |i: usize, dark: bool| {if dark { bits |= 1 << i; } };if copy == 1 {for (i, row) in modules.iter().enumerate().take(6) { put(i, row[8]); } put(6, modules[7][8]); put(7, modules[8][8]); put(8, modules[8][7]);for i in9..15usize { put(i, modules[8][14 - i]); } } else {for i in0..8usize { put(i, modules[8][size - 1 - i]); }for i in8..15usize { put(i, modules[size - 15 + i][8]); } } bits ^ 0x5412}/// Remainder of the 15-bit format value under the BCH(15,5) generator 0x537.fn bch_format_remainder(value: u32) -> u32 {letmut rem = value;for i in (10..=14usize).rev() {if (rem >> i) & 1 == 1 { rem ^= 0x537 << (i - 10); } } rem & 0x3ff}/// Read back one of the two copies of the 18-bit version information (v7+).fn read_version(m: &QrMatrix, copy: u8) -> u32 {let size = m.size;letmut bits = 0u32;for i in0..18usize {let a = size - 11 + (i % 3);let b = i / 3;let dark = if copy == 1 { m.modules[b][a] } else { m.modules[a][b] };if dark { bits |= 1 << i; } } bits}fn grid_of(matrix: &QrMatrix) -> String { matrix .modules .iter() .map(|row| { row.iter() .map(|&dark| if dark { '#' } else { '.' }) .collect::<String>() }) .collect::<Vec<_>>() .join("\n")}// ── encodeQr ─────────────────────────────────────────────────────────────────#[test]fn sizes_the_symbol_from_the_payloads_byte_length() {let v1 = "ABCD-2345";let v4 = r#"cotton-oauth:{"v":1,"server":"https://alex.relay.test"}"#;let v5 = r#"cotton-oauth:{"v":1,"server":"https://alex.relay.test","code":"ABCD2345"}"#;// Level-M byte capacities: v1 14, v2 26, v3 42, v4 62, v5 84. size = 17 + 4 * version. assert_eq!(byte_length(v1), 9); assert_eq!(byte_length(v4), 55); assert_eq!(byte_length(v5), 73); assert_eq!(encoded(v1).size, 21); assert_eq!(encoded(v4).size, 33); assert_eq!(encoded(v5).size, 37);}#[test]fn encodes_a_120_byte_payload_as_version_7_with_the_three_finder_patterns() {let text = format!("v7-payload-{}", "x".repeat(109)); assert_eq!(byte_length(&text), 120); // > 106 (v6) and <= 122 (v7)let m = encoded(&text); assert_eq!(m.size, 45); assert!(finder_at(&m.modules, 0, 0)); assert!(finder_at(&m.modules, 0, m.size - 7)); assert!(finder_at(&m.modules, m.size - 7, 0));}#[test]fn writes_the_version_information_twice_for_version_7_and_not_at_all_below_it() {let v7 = encoded(&format!("v7-payload-{}", "x".repeat(109))); assert_eq!(v7.size, 45);// ISO/IEC 18004 Table D.1, version 7: 000111 110010 010100. The table is// the authority here, not a second copy of the encoder's own BCH(18,6) loop. assert_eq!(read_version(&v7, 1), 0x07c94); assert_eq!(read_version(&v7, 2), 0x07c94);// Below version 7 the standard defines no version information and the area// is ordinary data — so the two would-be blocks disagree, where an encoder// that wrongly wrote version bits there would make them identical.let v6 = encoded(&"y".repeat(100)); assert_eq!(v6.size, 41); assert_ne!(read_version(&v6, 1), read_version(&v6, 2));}#[test]fn places_the_three_finder_patterns() {let m = encoded(r#"cotton-oauth:{"v":1,"server":"https://alex.relay.test","code":"ABCD2345"}"#); assert!(finder_at(&m.modules, 0, 0)); assert!(finder_at(&m.modules, 0, m.size - 7)); assert!(finder_at(&m.modules, m.size - 7, 0));}#[test]fn clears_the_separators_around_each_finder_pattern() {let m = encoded("separators");let size = m.size;for i in0..8usize { assert!(!m.modules[7][i]); assert!(!m.modules[i][7]); assert!(!m.modules[7][size - 1 - i]); assert!(!m.modules[i][size - 8]); assert!(!m.modules[size - 8][i]); assert!(!m.modules[size - 1 - i][7]); }}#[test]fn is_deterministic_and_square() {let a = encoded("hello");let b = encoded("hello"); assert_eq!(a, b); assert_eq!(a.modules.len(), a.size);for row in &a.modules { assert_eq!(row.len(), a.size); }}#[test]fn refuses_a_payload_above_what_version_10_at_level_m_holds() {let refusal = encode_qr(&"x".repeat(214)).expect_err("214 bytes is over the ceiling"); assert!(refusal.message.contains("too long")); assert_eq!(encoded(&"x".repeat(213)).size, 57);}#[test]fn a_refusal_is_a_qr_error_carrying_which_refusal_it_is() {// Both callers draw a person a sentence about this, and a sentence chosen// by matching on the message text is one that changes when somebody// rewords the throw. The kind is the contract.for (payload, kind) in [ (String::new(), QrErrorKind::Empty), ("x".repeat(214), QrErrorKind::TooLong), ] {let head: String = payload.chars().take(8).collect();letErr(refusal) = encode_qr(&payload) else { panic!("encode_qr({head:?}…) refused nothing"); }; assert_eq!(refusal.kind, kind);// Still an error with something to log: a caller that only prints it// loses nothing. assert_ne!(refusal.message, ""); assert_ne!(refusal.to_string(), ""); }}#[test]fn puts_the_timing_patterns_on_row_and_column_6() {let m = encoded("timing");for i in8..m.size - 8 { assert_eq!(m.modules[6][i], i % 2 == 0); assert_eq!(m.modules[i][6], i % 2 == 0); }}#[test]fn places_the_alignment_pattern_and_the_dark_module() {// 20 bytes: version 2, alignment centre (18, 18).let m = encoded(&"x".repeat(20)); assert_eq!(m.size, 25); assert!(alignment_at(&m.modules, 16, 16)); assert!(m.modules[m.size - 8][8]);}#[test]fn writes_valid_format_information_level_m_in_both_places() {for text in ["hello".to_string(), "x".repeat(60), "x".repeat(200)] {let m = encoded(&text);let first = read_format(&m, 1); assert_eq!(read_format(&m, 2), first); assert_eq!(bch_format_remainder(first), 0); assert_eq!((first >> 13) & 0b11, 0b00); // level Mlet mask = (first >> 10) & 0b111; assert!(mask <= 7); }}#[test]fn refuses_an_empty_payload() {let refusal = encode_qr("").expect_err("an empty payload has nothing to encode"); assert!(refusal.message.contains("empty"));}#[test]fn encodes_multi_byte_characters_by_their_utf_8_length() {// A 3-byte character: 5 of them is 15 bytes, one over version 1's 14.let text = "€".repeat(5); assert_eq!(byte_length(&text), 15); assert_eq!(encoded(&text).size, 25);}// ── rsEncode ─────────────────────────────────────────────────────────────────#[test]fn reproduces_the_iso_iec_18004_annex_i_error_correction_codewords() {// The standard's worked example: "01234567", version 1, level M — the data// codewords below, ten EC codewords.let data = [0x10, 0x20, 0x0c, 0x56, 0x61, 0x80, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11, 0xec,0x11, ]; assert_eq!( rs_encode(&data, 10), vec![0xa5, 0x24, 0xd4, 0xc1, 0xed, 0x36, 0xc7, 0x87, 0x2c, 0x55] );}#[test]fn returns_exactly_the_requested_number_of_codewords() { assert_eq!(rs_encode(&[1, 2, 3], 26).len(), 26); assert_eq!(rs_encode(&[0, 0, 0, 0], 18).len(), 18);}// ── qrSvg ────────────────────────────────────────────────────────────────────#[test]fn renders_one_path_inside_a_viewbox_with_a_four_module_quiet_zone() {let m = encoded("svg");let svg = qr_svg(&m, &QrSvgOptions::default()); assert!(svg.starts_with("<svg")); assert!(svg.contains(&format!(r#"viewBox="0 0 {} {}""#, m.size + 8, m.size + 8))); assert_eq!(svg.matches("<path").count(), 1); assert!(!svg.contains("<script"));}#[test]fn scales_by_module_size_and_quiet_zone() {let m = encoded("svg");let svg = qr_svg( &m, &QrSvgOptions { module_size: 4, quiet_zone: 2, ..QrSvgOptions::default() }, );let side = (m.size + 4) * 4; assert!(svg.contains(&format!(r#"viewBox="0 0 {side} {side}""#)));}#[test]fn paints_a_background_only_when_a_light_colour_is_given() {let m = encoded("svg"); assert!(!qr_svg(&m, &QrSvgOptions::default()).contains("<rect"));let painted = qr_svg( &m, &QrSvgOptions { light: "#fff".to_string(), ..QrSvgOptions::default() }, ); assert!(painted.contains("<rect")); assert!(painted.contains("#fff"));}#[test]fn escapes_the_colours_it_is_handed_so_a_colour_cannot_break_out_of_the_attribute() {let svg = qr_svg( &encoded("svg"), &QrSvgOptions { dark: r#""><script>alert(1)</script>"#.to_string(), ..QrSvgOptions::default() }, ); assert!(!svg.contains("<script")); assert!(svg.contains("""));}// ── the SVG a caller actually ships ──────────────────────────────────────────#[test]fn the_default_svg_for_hello_is_what_the_typescript_prints() {// BYTES, not a shape. `qrSvg`'s output is inlined verbatim into the consent// page, whose own suite compares the `<path>` against the TypeScript's, so// the two encoders have to agree on every coordinate, every run length and// the order the runs come out in — not merely on which modules are dark.// Printed by running `packages/core/src/qr/encode.ts` under Node. assert_eq!( qr_svg(&encoded("hello"), &QrSvgOptions::default()), HELLO_SVG );}const HELLO_SVG: &str = r##"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29" shape-rendering="crispEdges"><path fill="#000" d="M4 4h7v1h-7zM13 4h2v1h-2zM18 4h7v1h-7zM4 5h1v1h-1zM10 5h1v1h-1zM12 5h2v1h-2zM18 5h1v1h-1zM24 5h1v1h-1zM4 6h1v1h-1zM6 6h3v1h-3zM10 6h1v1h-1zM13 6h1v1h-1zM15 6h2v1h-2zM18 6h1v1h-1zM20 6h3v1h-3zM24 6h1v1h-1zM4 7h1v1h-1zM6 7h3v1h-3zM10 7h1v1h-1zM14 7h2v1h-2zM18 7h1v1h-1zM20 7h3v1h-3zM24 7h1v1h-1zM4 8h1v1h-1zM6 8h3v1h-3zM10 8h1v1h-1zM12 8h2v1h-2zM16 8h1v1h-1zM18 8h1v1h-1zM20 8h3v1h-3zM24 8h1v1h-1zM4 9h1v1h-1zM10 9h1v1h-1zM16 9h1v1h-1zM18 9h1v1h-1zM24 9h1v1h-1zM4 10h7v1h-7zM12 10h1v1h-1zM14 10h1v1h-1zM16 10h1v1h-1zM18 10h7v1h-7zM14 11h3v1h-3zM4 12h1v1h-1zM6 12h1v1h-1zM8 12h1v1h-1zM10 12h1v1h-1zM13 12h1v1h-1zM15 12h1v1h-1zM20 12h1v1h-1zM23 12h1v1h-1zM6 13h1v1h-1zM8 13h2v1h-2zM14 13h1v1h-1zM18 13h1v1h-1zM23 13h2v1h-2zM5 14h1v1h-1zM7 14h1v1h-1zM10 14h1v1h-1zM12 14h3v1h-3zM16 14h1v1h-1zM20 14h5v1h-5zM4 15h2v1h-2zM8 15h1v1h-1zM18 15h1v1h-1zM23 15h1v1h-1zM5 16h2v1h-2zM8 16h1v1h-1zM10 16h2v1h-2zM14 16h1v1h-1zM16 16h1v1h-1zM18 16h1v1h-1zM20 16h1v1h-1zM12 17h4v1h-4zM17 17h1v1h-1zM19 17h1v1h-1zM22 17h3v1h-3zM4 18h7v1h-7zM14 18h2v1h-2zM17 18h3v1h-3zM22 18h3v1h-3zM4 19h1v1h-1zM10 19h1v1h-1zM14 19h4v1h-4zM19 19h2v1h-2zM4 20h1v1h-1zM6 20h3v1h-3zM10 20h1v1h-1zM12 20h1v1h-1zM14 20h2v1h-2zM17 20h3v1h-3zM23 20h2v1h-2zM4 21h1v1h-1zM6 21h3v1h-3zM10 21h1v1h-1zM13 21h1v1h-1zM18 21h2v1h-2zM22 21h2v1h-2zM4 22h1v1h-1zM6 22h3v1h-3zM10 22h1v1h-1zM12 22h3v1h-3zM16 22h1v1h-1zM20 22h1v1h-1zM22 22h1v1h-1zM24 22h1v1h-1zM4 23h1v1h-1zM10 23h1v1h-1zM13 23h1v1h-1zM18 23h1v1h-1zM20 23h1v1h-1zM23 23h1v1h-1zM4 24h7v1h-7zM12 24h3v1h-3zM16 24h1v1h-1zM18 24h2v1h-2zM23 24h2v1h-2z"/></svg>"##;// ── reference matrices from an independent encoder ───────────────────────────/// One `fixtures/*.txt` from the TypeScript suite: the header's fields, then/// the grid.structFixture { name: &'static str, text: &'static str, version: usize, size: usize, grid: &'static str,}#[test]fn matches_qrcode_1_5_4s_reference_matrices_module_for_module() {for fixture in [Fixture { name: "hello-1M.txt", text: "hello", version: 1, size: 21, grid: FIXTURE_HELLO_1M, },Fixture { name: "pair-6M.txt", text: PAIR_6M_TEXT, version: 6, size: 41, grid: FIXTURE_PAIR_6M, },Fixture { name: "pair-long-8M.txt", text: PAIR_LONG_8M_TEXT, version: 8, size: 49, grid: FIXTURE_PAIR_LONG_8M, },Fixture { name: "ten-10M.txt", text: TEN_10M_TEXT, version: 10, size: 57, grid: FIXTURE_TEN_10M, }, ] {let matrix = encoded(fixture.text); assert_eq!(matrix.size, fixture.size, "{}: size", fixture.name); assert_eq!( matrix.size,17 + 4 * fixture.version,"{}: version {}", fixture.name, fixture.version );// The literals below open and close on their own lines so the grid// reads as a square in the source; the newlines that buys are the// layout's, not the fixture's. assert_eq!( grid_of(&matrix), fixture.grid.trim_matches('\n'),"{}: module for module", fixture.name ); }}const PAIR_6M_TEXT: &str =r#"cotton-pair:{"v":1,"server":"https://asha-example.relay.cottondb.com","code":"7X3K9QM2"}"#;const PAIR_LONG_8M_TEXT: &str = r#"cotton-pair:{"v":1,"server":"https://a-thirty-one-character-name-x.relay.cottondb.com","code":"7X3K9QM2","extra":"padding to reach version seven"}"#;const TEN_10M_TEXT: &str = r#"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"#;const FIXTURE_HELLO_1M: &str = r#"#######..##...########.....#.##....#.....##.###.#..#.##.#.###.##.###.#...##..#.###.##.###.#.##..#.#.###.##.....#.....#.#.....########.#.#.#.#######..........###........#.#.#.#..#.#....#..#...#.##....#...#....##.#.#..#.###.#...#######..#.........#....#..##.#.##..#.#.#.#............####.#.#..##########...##.###..####.....#...####.##....#.###.#.#.##.###...###.###.#..#....##..##.#.###.#.###.#...#.#.##.....#..#....#.#..#.#######.###.#.##...##"#;const FIXTURE_PAIR_6M: &str = r#"#######..##.#.#.#.##...#....#####.########.....#..#..#####.#...#....###....#.....##.###.#.##..#.###..#...##.#.#####.#.###.##.###.#.###.#..##.#####.#......#..#.###.##.###.#.##.###.....##..#..#.#.##..#.###.##.....#.#.###...##...##..#.#..#...#.....########.#.#.#.#.#.#.#.#.#.#.#.#.#.#######........##.####...####..#..#...#.........#.#####....#.#..##.##...###..#.#..#####..#.###....####.#.#.###..##.#..####.###..#..##.#.#........#.##..##....###....##.##...#.###....#######.##.##.#.#........#.#..#.#.##.#.#..##...##....#..#...##..#.#..##...###..#.##...###.#.#.#.##.##.#...###.#.#..##.##..##....#.###..#...#.....#.#.#.#..#....#......##....#####.#.#.#.#.#.###.....###.###.#..###..####.#.##...#.#......##......#.#.##....###.#.#.#.#..#.#######.#.###....##..##...#.#...#..#####.#.#...##.#.#...##.###..#..#####.#####.....###.##..####..###...#####......#..#.##..###...#.##....#...####.#.#...##.###....##.#..###.######...###.......#...#...#####.#.#..####....###...##.##.#.....##..#......#.#..#..#..#.#.##......#..##..#.##.#.###..#....####..#....#..##....#..#######..##.##.#####.######.##....#.##....##..#.##.#..##.#.###.##.###.#.#.##.###...##.##.#.....###.##.#.......##.#..#..###..#.#####.##.###.#.######.#.#...##..#.#..#..#.....#..#######..###..#..##...#..##.#..######.####...#.#.#..#.###......###.##....#.#...#..##.##..#.#.#.##.##.##..#.###.....####.#.##.#####.#.#........####.##.#..#...##...###.#...############...###...#.#.#.#.#..#.#.##.#.#.##.#.....#.##...#......#.....#.#####...##.###.###.#.#..##.##..#..###....#...#####.##.#.###.#.#.#.#..##..###.#..#.#.#..#.#..#..#.###.#.###.#.#####......#.#####.#####...#.....#...###.#...#.###....#..####..##.#.#######.##.###.#####..#..#.#####.#.###..."#;const FIXTURE_PAIR_LONG_8M: &str = r#"#######.###..#...####.###.##..#.######..#.########.....#.#####.#..#.#.#####.#...#..#...###.#.....##.###.#.#..##.##.#......####.##.###..#.##.#.###.##.###.#..#..#....####.#.#...###.#..###.#..#.###.##.###.#.#..#.###..#.#########.#.##.###....#.###.##.....#..###..##.###.##...#.#...##..###...#.....########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######...........##.####.####...####.#...#....#........#..######.#.##..###########.####.#.#####.#..#.#####..#..#.#..###.....#..##.#####..######.###..###..##...##..#..##..##..#......##..#####...##.#.#..######..##.##.#.#..#.###...##.##.####...#....###.#..##..###...####.#.##...#####...#.####.#.#.###...###..#...##....#.##..######.###......##...##......###.##.#.####...#.###.######.##.#.####.#..#..######.##..#.#..##..#.#.#....##.#....#...##.###.###....#######.#..###.##.#..#......###..#.#############.#...#.##..#..##....#.#..##.#####..#.##.#.##.#..#..#.#.##.####...##.##.##..##.##..##......##...##.##.#...#...#..######.#..###.#.#.#..#####.#.#..####..###.....##....##..##..##....#.#####........#..#.##....#.#########.#.########..##..######.###....#######.##.###.##.######.#..##.#..#..######..#.#..#...##...##.#.#..##...#....##.##.#..#...######.###.#.#.#.#####..#.##.#.####..#.#.#.###.#.##..##.#.#...#...##.#.#.####...##.##.##..###.#...###..##.######..##..####.#.#####.#....#...########...###.........###.##.##...##......#..##.#.#...#.########.#####..#.#..######...##...####.#.##..#..####....#..#..##.#.##.#...#.#.#..##.#.##.......#.###..#.#.####.###...##..#..#..###..##..###.####.###.#####....#..##.###.###.#.##..##...#...####..#.#....##...###.#.##.##..####...#.#....#.#####.#.###..#.##.##.##......#.#..#..##..#..#..#######.#######.....###.##..#....#####.#.###.#..#####.....#.##..#..###..#...##.###......####.#.###.##..##...#.###.....#.###....##...##..##....##.##.#.##.#.#.....###..###.##.#..#.####.#.######.###...#..#.###.#.##..#...###....#....####.#..#.##..#.#..#.#.#.#..####.###.....####.##.#.#.#..#.....#...#..#.#.....###.###...##.....#.#.##..######...###.#.###########..........#...#..#.##...#...###.#..##..#..#...##.#.#######.##.##.##.###..#.#.#..#..#..###.##.#.##..##.....#.##.###....##..#...###..#..#..##.#...##.#.#.###.#.##..##.##.##.######.####.#..##########.#.#.###.#.#...#...#..#...#.#.####.#.##.###..#..#####.###.#...#..##.##...#..#.....##.###.......###.#.#.....#...#..#.#...##..##..#.#######.#..#.#..###########.#...#.#.#.##..##.#..###.#.#.#.####..##..#"#;const FIXTURE_TEN_10M: &str = r#"#######........####...####.#.##.....##.#.##..###..########.....#...###.##..#####.######..#.#..#####..##.#..#.....##.###.#.#.#....##...##....#.#..#.###..#.#..#####..#.###.##.###.#.#.###.##.#.##..#......#..#.##.....##...#..#.###.##.###.#.###.#..##.#.#.###.######....##.#.##....#..#.###.##.....#.#.###.##.#..##..###...#...#..#####..#.#...#.....########.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#######........#.##.#.##.#.#....##...######..#.#..####..........#.#####...##.#.#...###.#.#######.#.##.....##.#.#..#####.....##...####..#.#.#.#..##.##.##.....##.#.##....###.#...#####.#.##..##.#...#..#.#.#..###..#.#..#####..#.#.#####.##.#.#..#.#..##.###..#.###..#.....#####..#.#..####...#.###..#.##..##..##.#.#...##.#.####..##.#.##.....##.#.#.....#..##.#.##..####..#...#.##.#.##..##.....##.#.##....###.#...#######.##.###.#...#..#.#...##.#..#.#..#####..#.#.#####.##.#..###.#.#.#..##..#.##.#.##.#..#####..#.#..####...#.###..#...####..##.#.#...##.##......##.#.##.....##.#.#.....#..##...##..##.#.#....##.#.##.##.##.....##.#.##....###.#...####.#####..##.#..####....#..###..#.#..#####..#.#.#####.##.#......###.#..##.##..#...#..##.#####..#.#..####...#.###..#...###.#..#.#.#...#.#.#.##....#.#.##.....##.#.#.....#..##......#.#..##......#.###.##.#......##.#.##....###.#...###..#####.#.###..#..#....#..##.#.#.#..#####..#.#.#####.##.#.........###.##.....#...#..#....###..#.#..####...#.###..#...#######.##.#..##.#.#.##...####.##.....##.#.#.....#..###.....#.#.#.#....#...###.##.##.#...##.#.##....###.#...####.#######.#.#..#.##....#.#######.#..#####..#.#.#####.##..#..#...#.##..##....##....#...######..#.#..####.#...###...####.#.###.##.##.##.#.#..#.#.##.#.##.....##.#..#.#.##..##.###...##..#.##..#...#####...#.....##.#.##....##...#..###...######.#....#.##....#######.#.#..#####..#.#######.##.....##.##.#..#.#....###..#####.#####..#.#..#####.######...#.#..#####.#..##.##...##...#..#.#.##.....##.#..#.#.##..#.#####.#.#..#.###.#..#..#.....#.....##.#.##.....#........#.##..#...##..##..##.#######.##.#.#..#####..#.##.#.#..###..####..#.#..##.....#...#.####.#####..#.#..#####.######...##..####...#..##.##.###...#...#.#.##.....##.#..#.#.##....#.#...#..#.###.#.#.##.##.#.#.#.....##.#.##.....#......###.##.##....#..###.#...#.#..####.#.#..#####..#.##.#.#..##....##...#.#..##..#.##....##.##.#####..#.#..#####.######...##..#######...##.####.#....#..#.#.##.....##.#..#.#.##..#.#.##..#.######.#...##.##.....#.....##.#.##.....#......######..#..##.#.#####...#.####.##.#.#..#####..#.##.#.#..##....#....##..###....#.....#####...###..#.#..#####.######...##...#######..##.####.#....#.#..#.##.....##.#..#.#.##..##..##..###..###.##..##.##....##.....##.#.##.....#......###.#..##..##...###..##.#.####..#.#.#..#####..#.##.#.#..##.#####..#.#.###.....#.....###########..#.#..#####.######........#..##..#..#.####.#..######.#.##.....##.#..######..#........##.#..#.###.##.##.#...#.....##.#.##.....#...#..#########..##.#..##..####.#.#.#.#.#.#..#####..#.#.#.#.#.##.#.....#.##.#.#.##..#......#...######..#.#..####.#...###..#.###.#.###....##.####..########.#.##.....##.#.#######..##.###.#.##.#..##.##.#..#.##.#.......##.#.##....#..#.#....#.###.#.#.#.###....####...#...#.#.#..#####..#.###.....#..#.....#..#.#....#..#..##...#.#######..#.#..####.##.#.##..#######.##...##...##.###.#.###.#.#.##.....##.#...#####.#."#;