package com.javarush.task.task18.task1809;

/*
Реверс файла
*/

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Solution {
    public static void main(String[] args) {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            String file1 = bufferedReader.readLine();
            String file2 = bufferedReader.readLine();
            FileInputStream fileInputStream = new FileInputStream(file1);
            FileOutputStream fileOutputStream1 = new FileOutputStream(file2);
//            BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
//            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream1);

//            List<Integer> list1 = new ArrayList<Integer>();
            int a = fileInputStream.available();
            byte[] mas = new byte[a];
            int masLength = fileInputStream.read(mas);

//            while (fileInputStream.available() > 0) {
//                list1.add(fileInputStream.read());
//            }

            for (int i = 0, size = mas.length, len = size/2, indexToSwap, tmp; i < len; i ++) {
                tmp = mas[i];
                indexToSwap = size - i - 1;
                mas[i] = (byte) indexToSwap;
                mas[indexToSwap] = (byte) tmp;
            }

//            for (int i = 0, size = list1.size(), len = (size / 2), indexToSwap, tmp; i < len; ++i) {
//                tmp = list1.get(i);  // сохраняем значение элемента "с начала"
//                indexToSwap = size - 1 - i;  // узнаем индекс симметричного элемента "с конца"
//                list1.set(i, list1.get(indexToSwap));  // устанавливаем элементу "с начала" значение элемента "с конца"
//                list1.set(indexToSwap, tmp);  // устанавливаем  элементу "с конца" значение элемента "с начала"
//            }

//            for (int a = 0; a < list1.size(); a++) {
//                fileOutputStream1.write(list1.get(a));
//            }

            fileOutputStream1.write(mas, 0, masLength);

            fileInputStream.close();
            fileOutputStream1.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}