#define rx 19
Serial1.begin(38400);
pinMode(rx, INPUT);
You told the Serial1 instance that it could use the pin. Then you diddle with the pin. Why?
You are sending data to the 328's serial port faster than the mega can read it and print it. After a while the buffer fills up, and data gets lost.