/***************************************************
Print town names from census data
***************************************************/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
int main()
{
  // User enters file name
  string file;
  cout << "Enter name of input file: ";
  cin >> file;
 
  // Open census data file
  ifstream fin(file.c_str());
  if (!fin)
  {
    cout << "Error opening file!" << endl;
    return 0;
  }
 
  // Read in (and ignore!) header information
  string kill;
  fin >> kill;
  while(kill != "NAME")
    fin>> kill;
 
  // Loop over each row
  string s;
  while(fin >> s)
  {    
    /***** Process row **************/
    // Read (and ignore) 7 entries
    fin >> s >> s >> s >> s >> s >> s;
 
    // Read name of city/town/CDP/village
    string t, N;
    fin >> t;
    while(t != "town" && t != "city" && t != "CDP" && t != "village")
    {
      N = N + t;
      fin >> t;
    }
 
    // Print name if town
    if (t == "town")
      cout << N << endl;
  }
 
  return 0;
}