import java.util.*; public class App { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String[] temp = sc.nextLine().split(" "); int N = Integer.parseInt(temp[0]);//アイテムの個数 int P = Integer.parseInt(temp[1]);//剣の攻撃力 int K = Integer.parseInt(temp[2]);//装備するアイテム int T , B , _Max_Power = 0; String[] _attack_power = new String[N]; for(int i = 0; i < N; i++){ _attack_power[i] = sc.nextLine(); } for(int i = 0; i <= N - K; i++){ int _attack_power_count = P; for(int j = 0 + i; j < K + i; j++){ String[] item_type = _attack_power[j].split(" "); T = Integer.parseInt(item_type[0]); B = Integer.parseInt(item_type[1]); if(T == 1){ _attack_power_count += B; } else if(T == 2){ _attack_power_count = _attack_power_count * 2; } } if(_attack_power_count > _Max_Power){ _Max_Power = _attack_power_count; } } System.out.println(_Max_Power); } }