public int motorUse(String[] prices, String[] purchases) {
		int running = 0;
		
		// Convert input prices
		int cols = prices.length;
		mInventory = new Inventory(prices.length);
		
		for (int i=0; i<cols; i++) {
			String temp[] = prices[i].split(" ");
			int shelves = temp.length;
			mInventory.columns[i] = new Column(shelves);
			for (int j=0; j<shelves; j++) {
				mInventory.columns[i].put(j, Integer.valueOf(temp[j]));
			}
		}
		
		// Verify
		if (LOGD) {
			System.out.println("columns=" + mInventory.cols + " shelves=" + mInventory.columns[0].shelves);
			for (int i=0; i<mInventory.cols; i++) {
				Column col = mInventory.columns[i];
				for (int j=0; j<col.shelves; j++) {
					System.out.println("Column " + i + " Shelf " + j + " has " + col.get(j));
				}
			}
			System.out.println("");
		}

		// Start
		mCurrentColumn = 0;

		// move to the most expensive columns after power on.
		running = moveToExpensiveColumn();
		
		// Convert input purchases
		int purchase_length = purchases.length;
		Purchase purchase[] = new Purchase[purchase_length];
		for (int i=0; i<purchase_length; i++) {
			purchase[i] = new Purchase(purchases[i]);

			// Calculate.
			int moved = buy(purchase[i]);
			if (moved==-1) {
				if (LOGD) System.out.println("Invalid. return -1");
				return -1;
			} else {
				running += moved;
			}
		}

		/*
		// move to the most expensive columns at the end of the simulation
		moveToExpensiveColumn();
*/
		if (LOGD) {
			System.out.println("");
			System.out.println("running=" + running);
		}
		
		return running;
	}