// Arup Guha
// 7/20/02
// Solution for contest problem parity. Reads in an input file with
// several lines of 0s and 1s and outputs these bits along with their
// parity, separated by a space.
#include <iostream.h>
#include <fstream.h>

void main() {

  ifstream fin("parity.in");
  char digits[8];
  int i;
  
  // Read in all the data. Initially I had !fin.eof() as my boolean
  // condition, but that ended up producing one extra line of output.
  while (fin >> digits[0]) {
 
    // Print out first bit of the line.
    cout << digits[0];

    // Initialize sum to the correct parity.
    int sum = (int)(digits[0]-'0');

    // For the next 7 bits, read them in, output them, and adjust the
    // sum of 1s, if necessary.
    for (i=1; i<8; i++) {
      fin >> digits[i];
      cout << digits[i];
      if (digits[i] == '1')
        sum++;
    }

    // Output parity information and newline character.
    if (sum%2 == 1)
      cout << " 1" << endl;
    else
      cout << " 0" << endl;

  }
  fin.close();
}
