/************************************************
Grundlegende Algorithmen mit Java,
http://algorithmen-und-problemloesungen.de/
Copyright @2007-2008 by Doina Logofatu
************************************************/

import java.io.*;
import java.util.*;

public class P01Rucksack {

  private static final String FileInputName = "rucksack.in";
  private static final String FileOutputName = "rucksack.out";

  public static void main(String[] args) throws IOException {
    Scanner scanner = null;
    PrintStream out = null;
    try {
      scanner = new Scanner(new File(FileInputName)).useLocale(Locale.ENGLISH);
      out = new PrintStream(new File(FileOutputName));
      if (!scanner.hasNextFloat())
        return;
      float M = scanner.nextFloat();
      List<RucksackObject> v = new ArrayList<RucksackObject>();
      int index = 0;
      while (scanner.hasNextFloat()) {
        float weight = scanner.nextFloat();
        if (!scanner.hasNextFloat())
          break;
        float value = scanner.nextFloat();
        v.add(new RucksackObject(++index, weight, value));
      }

      Collections.sort(v);
      int i = v.size() - 1;
      while (i >= 0 && M > 0) {
        float wgt = v.get(i).getWeight();
        if (M >= wgt) {
          M -= wgt;
          --i;
        } else {
          M = -M;
        }
      }
      for (int j = v.size() - 1; j > i; --j) {
        out.print(v.get(j));
        out.println(" - complet");
      }
      if (i >= 0 && M < 0) {
        out.print(v.get(i));
        out.print(" - ");
        out.print(-M);
        out.print(" kg");
      }
    } finally {
      if (scanner != null) {
        scanner.close();
      }
      if (out != null) {
        out.close();
      }
    }
  }
}

class RucksackObject implements Comparable<RucksackObject> {
  private int index;
  private float weight, value;

  RucksackObject(int index, float weight, float value) {
    this.index = index;
    this.weight = weight;
    this.value = value;
  }

  /** @see java.lang.Comparable#compareTo(java.lang.Object) */
  public int compareTo(RucksackObject other) {
    float diff = this.value / this.weight - other.value / other.weight;
    return diff > 0f ? 1 : (diff < 0f ? -1 : 0);
  }

  /** @see java.lang.Object#toString() */
  public String toString() {
    return "Obiect " + this.index + ": " + this.weight + ' ' + this.value;
  }

  public float getWeight() {
    return weight;
  }
}
