
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	private String name;
	private int q;

	//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQ() {
		return q;	
	}

	public void setQ(int q) {
		this.q = q;
	}
	

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	}
}
 import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util public class Main {
	
	private String name;
	private int q;

	//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQ() {
		return q;	
	}

	public void setQ(int q) {
		this.q = q;
	}
	

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	}
} Main private String name; name private int q; q //construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	} Main {
		this.name = name;
		this.q = q;
	} this.name = name this.name this this.name name this.q = q this.q this this.q q String name name int q q public String getName() {
		return name;
	} getName {
		return name;
	} return name; name public void setName(String name) {
		this.name = name;
	} setName {
		this.name = name;
	} this.name = name this.name this this.name name String name name public int getQ() {
		return q;	
	} getQ {
		return q;	
	} return q; q public void setQ(int q) {
		this.q = q;
	} setQ {
		this.q = q;
	} this.q = q this.q this this.q q int q q public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	} main {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) Queue<Main> queue = new LinkedList<Main>(); queue new LinkedList<Main>() String firstLine = in.nextLine(); firstLine in.nextLine() in.nextLine in Scanner first = new Scanner(firstLine); first new Scanner(firstLine) int items = Integer.parseInt(first.next()); items Integer.parseInt(first.next()) Integer.parseInt Integer first.next() first.next first int quantum = Integer.parseInt(first.next()); quantum Integer.parseInt(first.next()) Integer.parseInt Integer first.next() first.next first for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		} int i = 0; int i = 0; i 0 i < items i items i++ i++ i {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		} {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		} String line = in.nextLine(); line in.nextLine() in.nextLine in Scanner linereader = new Scanner(line); linereader new Scanner(line) String itemName = linereader.next(); itemName linereader.next() linereader.next linereader int itemQ = Integer.parseInt(linereader.next()); itemQ Integer.parseInt(linereader.next()) Integer.parseInt Integer linereader.next() linereader.next linereader queue.add(new Main(itemName, itemQ)) queue.add queue new Main(itemName, itemQ) int turnCounter = 0; turnCounter 0 while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		} !queue.isEmpty() queue.isEmpty() queue.isEmpty queue {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		} Main next = queue.remove(); next queue.remove() queue.remove queue int qCheck = next.getQ() - quantum; qCheck next.getQ() - quantum next.getQ() next.getQ next quantum if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			} qCheck <= 0 qCheck 0 {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			} turnCounter+= next.getQ() turnCounter next.getQ() next.getQ next next.setQ(turnCounter) next.setQ next turnCounter System.out.println(next.getName() + " " + next.getQ()) System.out.println System.out System System.out next.getName() + " " + next.getQ() next.getName() + " " + next.getQ() next.getName() next.getName next " " next.getQ() next.getQ next {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			} turnCounter += quantum turnCounter quantum next.setQ(qCheck) next.setQ next qCheck queue.add(next) queue.add queue next String[] args args public class Main {
	
	private String name;
	private int q;

	//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQ() {
		return q;	
	}

	public void setQ(int q) {
		this.q = q;
	}
	

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	}
} public class Main {
	
	private String name;
	private int q;

	//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQ() {
		return q;	
	}

	public void setQ(int q) {
		this.q = q;
	}
	

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	}
} Main

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	private String name;
	private int q;

	//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
	public Main(String name, int q) {
		this.name = name;
		this.q = q;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQ() {
		return q;	
	}

	public void setQ(int q) {
		this.q = q;
	}
	

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		Queue<Main> queue = new LinkedList<Main>();
		
		//scan first line to get number of processes and the universal quantum
		String firstLine = in.nextLine();
		Scanner first = new Scanner(firstLine);
		int items = Integer.parseInt(first.next());
		int quantum = Integer.parseInt(first.next());

		//create queue with data from file
		for(int i = 0; i < items; i++) {
			String line = in.nextLine();
			Scanner linereader = new Scanner(line);
			
			String itemName = linereader.next();
			int itemQ = Integer.parseInt(linereader.next());
			
			queue.add(new Main(itemName, itemQ));
		}
		
		int turnCounter = 0;
		while(!queue.isEmpty()) {
			Main next = queue.remove();
			int qCheck = next.getQ() - quantum;
			
			//if item completes
			if(qCheck <= 0) {
				turnCounter+= next.getQ();
				next.setQ(turnCounter);
				System.out.println(next.getName() + " " + next.getQ());
			}
			//else if it has time remaining
			else {
				turnCounter += quantum;
				next.setQ(qCheck);
				queue.add(next);
			}
		}
	}
}

