#include <iostream>
#include <algorithm>
#include <iterator>
#include <utility>

namespace hoge {

// intとdoubleを読み込むイテレータ
class my_iter
  : public std::iterator< std::forward_iterator_tag, my_iter> {

public:
  // Constructors
  my_iter()
    : stream_(0), eof_(true), values_(std::pair< int, double>()) {
    // デフォルトはeofとする
  }

  explicit my_iter(std::istream *stream)
    : stream_(stream), eof_(false), values_(std::pair< int, double>()) {
    read();
  }

  // Copy
  my_iter(my_iter const &other)
    : stream_(other.stream_), eof_(other.eof_), values_(other.values_) {
  }

  my_iter& operator=(my_iter const &other) {
    if(this != &other) {
      my_iter(other);
      std::swap(*this, other);
    }
    return *this;
  }

  // Move
  my_iter(my_iter &&other)
    : stream_(0), eof_(true), values_(std::pair< int, double>()) {
    std::swap(stream_, other.stream_);
    std::swap(eof_, other.eof_);
    std::swap(values_, other.values_);
  }

  my_iter& operator=(my_iter &&other) {
    if(this != &other)
      std::swap(*this, other);
    return *this;
  }

  // 前置
  my_iter& operator++() {
    read();
    return *this;
  }

  // デリファレンス
  std::pair< int, double>& operator*() {
    return values_;
  }

  // 比較
  friend bool operator==(my_iter const &lhs, my_iter const &rhs) {
    return lhs.eof_ && rhs.eof_; // 両方がeofだったらイコール
  }

  friend bool operator!=(my_iter const &lhs, my_iter const &rhs) {
    return !(lhs == rhs);
  }

private:

  // 読み込み
  void read() {
    if(!eof_)
      if(!(*stream_).eof()) {
        *stream_ >> values_.first;
        if(!(*stream_).eof())
          *stream_ >> values_.second;
        else
          eof_ = true;
      } else
        eof_ = true;
  }

  std::istream *stream_; // ストリーム
  bool eof_; // eofに達したかどうか
  std::pair< int, double> values_; // 読み込んだ値
};

} // namespace hoge

// ---- MAIN ---

using namespace std;
using namespace hoge;
int main() {
  int i=0;

  my_iter it(&cin);
  my_iter it_end;

  for_each(it, it_end,
    [&i](pair< int, double> const &v) {
      ++i;
      if(v.second < 0.0)
        cout << "fail (line=" << i << ")" << endl;
      else
        cout << v.first << " " << v.second << endl;
    }
  );
}
