package com.javarush.task.pro.task15.task1504;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.NoSuchElementException;
import java.util.Scanner;

/*
Перепутанные байты
*/

public class Solution {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(new InputStreamReader(System.in)); InputStream input = Files.newInputStream(Paths.get(scanner.next())); OutputStream output = Files.newOutputStream(Paths.get(scanner.next()))) {
            byte[] buffer = input.readAllBytes();
            byteFlipper(buffer);
            output.write(buffer, 0, buffer.length);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        finally {
            System.out.println("Copied successfully");
        }
    }

    public static void byteFlipper(byte[] array) {
        int arrayItemsAmount = 0;
        if (array[array.length - 1] % 2 == 0) {
            arrayItemsAmount = array.length - 2;
        }
        else
            arrayItemsAmount = array.length;

        for (int i = 0; i < arrayItemsAmount; i += 2) {
            byte temp = array[i];
            array[i] = array[i + 1];
            array[i + 1] = temp;
            }
        }
}