import java.util.*;
class Player6{
	protected int maxHp;
	protected int hp;
	protected int mp;
	protected int place;
	protected int ratio;
	protected Random rnd;
    public Player6(int maxHp, int mp, int ratio) {
        this.maxHp = maxHp; // 最大HPのセット
        this.hp = maxHp;    // 現在HPを最大HPで初期化
        this.mp = mp;       // MPのセット
        this.ratio = ratio; // 回復確率のセット
        this.rnd = new Random(); // ランダムオブジェクトの生成
        this.place = 0;     // 初期位置を0に設定
    }

	public  boolean isAlive(){
		return hp>=1;
	}

    public void work() {
        if (isAlive()) { // 生存している場合のみ行動する
            int chance = rnd.nextInt(100); // 0から99のランダムな数を生成
            if (chance < ratio) { // 回復を試みる (ratio% の確率)
                if (mp > 0) {
                    hp = maxHp; // HPを最大値に回復
                    mp--;       // MPを1減らす
                    System.out.println("Healing successful! HP restored to max.");
                } else {
                    hp--;       // HPを1減らす（回復失敗）
                    System.out.println("Healing failed! Not enough MP.");
                }
            } else { // 前に進む (100 - ratio% の確率)
                place++; // 位置を1進める
                hp--;    // HPを1減らす
                System.out.println("Moved forward.");
            }
        }
    }
    public void printStatus() {
        System.out.println("HP: " + hp + ", MP: " + mp + ", Place: " + place);
    }
	
}
class Game6 {
    public static void main(String[] args) {
        // Player6型のインスタンスを作成（引数例: maxHp=10, mp=3, ratio=50）
        Player6 p = new Player6(10, 3, 50);
        play(p);
    }
    public static void play(Player6 p) {
        while (p.isAlive()) { // プレイヤーが生存している間ループ
            p.work();         // 行動
            p.printStatus();  // ステータスを表示
        }
        System.out.println("Player has died. Game over.");
    }
}
