Problem: ACM countries have rivers that flow from east to west in the center. This river flows from the neighboring country in the west through the neighboring country in ACM to the neighboring country in the east, and the total length in ACM is K km. It is planned to install several locks on this river and use it as a canal.

A lock is a mechanism for a ship to move between two different water levels. Locks have locks on the upstream and downstream sides, respectively, and a small body of water called a lock chamber between them. After putting the ship in this lock room, water is injected or drained, and the water level in the lock room is raised or lowered to raise or lower the ship. The schematic diagram is shown below.

<image>
Figure F-1: Schematic diagram of the lock

Since the width of this river is not very wide, it has been decided that it will be a one-way canal from west to east. The person in charge of design wants to optimize the location of the lock according to the expected navigation schedule of the ship in order to operate the canal efficiently.

You are a programmer hired by a designer. Your job is to write a program that simulates the time it takes for all ships to cross the river, given the lock information and the navigation schedules for multiple ships.

Each lock is represented by the following information.

* Distance from the western end of ACM country X (km)
* Volume of water required to switch the water level L (L)
* Maximum water injection amount per unit time F (L / h)
* Maximum displacement per unit time D (L / h)
* Hierarchical relationship between the water level on the west side and the water level on the east side of the lock



For convenience, in the simulation, it is assumed that the river continues infinitely outside the ACM as well.

At the start of the simulation, the water levels in all the lock chambers are the lower of the eastern and western water levels. In addition, the ships included in the navigation schedule shall be lined up every 1 km from east to west in the order given by input, starting from the western end of the ACM country. For convenience, the initial position of the leading ship is set to the 0km point.

As soon as the simulation starts, the ship begins to sail east. At this time, no other ship should enter less than 1km before and after one ship. The maximum speed V (km / h) is set for each ship. The ship can reach any speed in an instant and even stand still in an instant. Basically, a ship sails at the maximum speed, but if the following ship has a faster maximum speed than the preceding ship and the following ship catches up 1 km before the preceding ship, the following ship will lead. It sails at the same speed as the ship. The size of the ship and locks shall be negligible.

A ship can enter the lock only when the water level on the west side of the lock is equal to the water level in the lock chamber. Similarly, you can exit the lock only when the water level on the east side of the lock is equal to the water level in the lock chamber. If there is no ship inside, the water level in each lock will rise or fall until it matches the water level on the west side of the lock. If there is a ship, it will be displaced until it matches the water level on the east side of the lock. Even if the ship is moored just 1km away from the lock, the ship can leave the lock. However, at this time, the ship must berth at the exit from the lock until the preceding ship starts.

After passing the eastern end of the ACM country, the ship sails to infinity as fast as possible. The simulation ends when all ships have passed the eastern end of the ACM country.



Input

The input consists of multiple datasets. Each dataset is given in the following format.

> NMK
> X1 L1 F1 D1 UD1
> X2 L2 F2 D2 UD2
> ...
> XN LN FN DN UDN
> V1
> V2
> ...
> VM
>

The first line consists of three integers N, M, K. N (1 ≤ N ≤ 100) is the number of locks, M (1 ≤ M ≤ 100) is the number of ships, and K (2 ≤ K ≤ 1000) is the total length of the river in ACM.

The following N lines represent lock information. Each line consists of 5 integers Xi, Li, Fi, Di, UDi. Xi (1 ≤ Xi ≤ K -1) is the position of lock i from the western end of the ACM country (km), Li (1 ≤ Li ≤ 1000) is the volume of water required to switch the water level of lock i (L), Fi (1 ≤ Fi ≤ 1000) is the maximum water injection amount per unit time of lock i (L / h), Di (1 ≤ Di ≤ 1000) is the maximum drainage amount per unit time of lock i (L / h), UDi ( UDi ∈ {0, 1}) represents the hierarchical relationship between the water level on the west side and the water level on the east side of the lock i, respectively. When UDi is 0, the lock i means that the water level is higher on the east side than on the west side. On the other hand, when UDi is 1, lock i means that the water level is lower on the east side than on the west side.

The following M rows are given the integer Vi (1 ≤ Vi ≤ 1000), which represents the maximum speed (km / h) of the i-th vessel in each row.

Locks are given in ascending order of Xi values. In addition, multiple locks will not be installed at the same position.

The end of the input consists of three zeros separated by spaces.

Output

For each dataset, output the time from the start to the end of the simulation in one line. The output value may contain an error of 10-6 or less. The value may be displayed in any number of digits after the decimal point.

Example

Input

1 1 100
50 200 20 40 0
1
2 4 100
7 4 1 4 1
19 5 1 4 0
5
3
7
9
1 2 3
1 1 1 1 0
1
3
1 2 10
5 10 1 1 1
2
3
0 0 0


Output

110
46.6666666667
5
41.6666666667

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
//#define EPS 0.000000001
using namespace std;

#define EPS 0.0000001
#define NUM 105

enum Type{
	CATCH_UP,
	ARRIVE_ROOM,
	WATER_UP,
	WATER_DOWN,
	FINISH,
};

enum Water{
	West,
	East,
	Moving,
};

struct Info{
	void set(double arg_loc,double arg_down_time,double arg_up_time,bool arg_is_east_higher){
		loc = arg_loc;
		down_time = arg_down_time;
		up_time = arg_up_time;
		is_east_higher = arg_is_east_higher;
	}
	double loc,down_time,up_time,move_end_time;
	bool is_east_higher;
	int wait_ship_id;
	Water water,next_water;
};

struct Ship{
	void set(double arg_current_loc,int arg_max_speed,int arg_current_speed){
		current_loc = arg_current_loc;
		max_speed = arg_max_speed;
		current_speed = arg_current_speed;
	}
	double current_loc;
	bool is_waiting;
	int last_room,max_speed,current_speed;
};

struct Data{
	Data(){
		event_time = 0;
		ship_id = 0;
		room_id = 0;
		type = CATCH_UP;
	}
	Data(double arg_event_time,int arg_ship_id,int arg_room_id,Type arg_type){
		event_time = arg_event_time;
		ship_id = arg_ship_id;
		room_id = arg_room_id;
		type = arg_type;
	}
	bool operator<(const struct Data &arg) const{
		return event_time > arg.event_time;
	}
	double event_time;
	int ship_id,room_id;
	Type type;
};

int num_room,num_ship;
int debug_array[NUM];
double LENGTH;
Info info[NUM];
Ship ship[NUM];

void set_speed(int ship_head){

	//★前の船との距離がちょうど1kmで、1つ前の航行速度より最大速度が速いなら、1つ前のスピードに合わせる
	for(int i = ship_head+1; i < num_ship; i++){

		if(ship[i].is_waiting)continue; //閘門の中ならSKIP

		if(ship[i-1].current_loc-ship[i].current_loc > 1.0){ //距離が1より大きい

			ship[i].current_speed = ship[i].max_speed;
			continue;
		}

		//距離がちょうど1
		if(ship[i].max_speed > ship[i-1].current_speed){

			ship[i].current_speed = ship[i-1].current_speed;
		}else{

			ship[i].current_speed = ship[i].max_speed;
		}
	}
}

void calc_loc(int ship_head,double add_time){

	for(int i = ship_head; i < num_ship; i++){
		ship[i].current_loc += ship[i].current_speed*add_time;
	}
}

//ある船が、ある閘門に到着するまでの時間を求める
double calc_time(int ship_id,int room_id){

	double dist = info[room_id].loc-ship[ship_id].current_loc;
	return dist/(double)ship[ship_id].current_speed;
}

void func(){

	double X,L,F,D;
	int UD;

	double first_time = BIG_NUM;
	Type first_event = ARRIVE_ROOM;
	int first_ship,first_room;

	//閘門の情報を取得
	for(int i = 0; i < num_room; i++){

		scanf("%lf %lf %lf %lf %d",&X,&L,&F,&D,&UD);
		info[i].set(X,L/D,L/F,UD == 0);

		//シミュレーションの開始時点において、水位は低い方に合っている
		if(info[i].is_east_higher){
			info[i].water = West;
		}else{
			//★★★西側の水位に合わせる★★★
			info[i].water = Moving;
			info[i].next_water = West;
			info[i].move_end_time = info[i].up_time;
			if(first_time > info[i].up_time){
				first_time = info[i].up_time;
				first_event = WATER_UP;
				first_ship = -1;
				first_room = i;
			}
		}
		info[i].wait_ship_id = -1; //★待っている船があれば、そのidを持つ★
	}
	info[num_room].loc = LENGTH; //★時間計算簡易化のため★

	int tmp_speed;

	//船の情報を取得
	for(int i = 0; i < num_ship; i++){

		scanf("%d",&tmp_speed);
		ship[i].set(-1*i,tmp_speed,tmp_speed);
		ship[i].last_room = -1; //最後に通過した閘門のインデックス
		ship[i].is_waiting = false;
		debug_array[i] = 0;
	}

	int tmp_id,next_ship,next_room;
	double ans = BIG_NUM;
	double tmp_time;

	Type next_type;

	//★最初は1km等間隔に並んでいるため、まず船の速度を設定する★
	set_speed(0);

	/*★★船の速度が変化するイベントは、前のものが終わるまで、次のものをpushしない★★*/

	priority_queue<Data> Q;

	if(first_event == ARRIVE_ROOM){

		Q.push(Data(calc_time(0,0),0,0,ARRIVE_ROOM)); //全ての閘門の水位が西に合っているなら、先頭の船のイベントを追加
	}else{

		tmp_time = calc_time(0,0);

		if(tmp_time < first_time){

			Q.push(Data(tmp_time,0,0,ARRIVE_ROOM));
		}else{

			Q.push(Data(first_time,first_ship,first_room,first_event));
		}
	}

	Data data;
	double current_time,pre_time = 0,next_time;
	int ship_head = 0;

	while(true){

		data = Q.top();
		Q.pop();

		current_time = Q.top().event_time;
		//★★船全体を動かす★★
		if(fabs(current_time-pre_time) > EPS){
			calc_loc(0,current_time-pre_time);
		}

		switch(data.type){
		case CATCH_UP: //ある船が別の船の1km後方に到達した場合

			ship[data.ship_id].current_speed = ship[data.ship_id-1].current_speed;
			set_speed(data.ship_id); //影響を後ろに伝播させる

			break;

		case ARRIVE_ROOM: //ある船がある閘門に到達した場合

			//閘門の中ではspeed0とする
			ship[data.ship_id].current_speed = 0;
			ship[data.ship_id].is_waiting = true;
			//自分以降の船に、停止情報を伝える
			set_speed(data.ship_id);

			info[data.room_id].wait_ship_id = data.ship_id; //★とりあえず待つ★

			if(info[data.room_id].water == West){ //水位が西側に合っている場合のみ中に入る

				if(info[data.room_id].is_east_higher){

					info[data.room_id].move_end_time = current_time+info[data.room_id].up_time;
				}else{
					info[data.room_id].move_end_time = current_time+info[data.room_id].down_time;
				}
				info[data.room_id].water = Moving;
				info[data.room_id].next_water = East;
			}

			break;

		case WATER_UP:

			if(info[data.room_id].is_east_higher){ //東の方が水位が高い場合

				//★基本的に閘門の水位は西側に合わせるので、必ず船がいるはず
				tmp_id = info[data.room_id].wait_ship_id;
				ship[tmp_id].last_room = data.room_id; //通過済とする
				ship[tmp_id].is_waiting = false;
				debug_array[tmp_id]++;
				info[data.room_id].wait_ship_id = -1;

				//★閘門を通過した船の速度を設定する
				if(tmp_id == 0){

					ship[tmp_id].current_speed = ship[tmp_id].max_speed;
					set_speed(tmp_id); //影響を伝播させる

				}else{ //自分が先頭でないなら、自分の1つ前から計算すれば良い

					set_speed(tmp_id-1);
				}

				//閘門の水位が動き終わる時刻等を設定
				info[data.room_id].water = Moving;
				info[data.room_id].move_end_time = current_time+info[data.room_id].down_time;
				info[data.room_id].next_water = West;

			}else{ //西側の方が水位が高い場合(★船は中にいないが、手前で待っている場合あり★)

				info[data.room_id].water = West;
				if(info[data.room_id].wait_ship_id != -1){ //水位の変動を待っている船がいる場合

					info[data.room_id].water = Moving;
					info[data.room_id].move_end_time = current_time+info[data.room_id].down_time;
					info[data.room_id].next_water = East;
				}
			}
			break;
		case WATER_DOWN:

			if(info[data.room_id].is_east_higher){ //東の方が水位が高い場合(★船は中にいないが、手前で待っている場合あり★)

				info[data.room_id].water = West;
				if(info[data.room_id].wait_ship_id != -1){ //水位の変動を待っている船がいる場合
					info[data.room_id].water = Moving;
					info[data.room_id].move_end_time = current_time+info[data.room_id].up_time;
					info[data.room_id].next_water = East;
				}

			}else{ //西側の方が水位が高い場合

				//★基本的に閘門の水位は西側に合わせるので、必ず船がいるはず
				tmp_id = info[data.room_id].wait_ship_id;
				ship[tmp_id].last_room = data.room_id; //通過済とする
				ship[tmp_id].is_waiting = false;
				info[data.room_id].wait_ship_id = -1;
				debug_array[tmp_id]++;

				//★閘門を通過した船の速度を設定する:仮に自分が先頭でないなら、自分の1つ前から計算すれば良い★
				if(tmp_id == 0){

					ship[tmp_id].current_speed = ship[tmp_id].max_speed;
					set_speed(tmp_id); //影響を伝播させる

				}else{

					set_speed(tmp_id-1);
				}

				//閘門の水位が動き終わる時刻等を設定
				info[data.room_id].water = Moving;
				info[data.room_id].move_end_time = current_time+info[data.room_id].up_time;
				info[data.room_id].next_water = West;
			}

			break;
		case FINISH: //ある船が川を抜けた場合

			ans = current_time;

			ship_head++;
			break;
		}

		if(ship_head == num_ship)break;

		/*★★★最も早く起こる、次のイベントを計算★★★*/
		next_time = BIG_NUM;

		//船を走査
		for(int i = 0; i < num_ship; i++){

			if(fabs(ship[i].current_speed) < EPS){ //★閘門前、または前が詰まっているために待ち状態ならSKIP

				//★★★ぴったり、閘門の前で止まっている場合あり★★★
				if(fabs(ship[i].current_loc-info[ship[i].last_room+1].loc) < EPS && ship[i].is_waiting == false){

					next_time = current_time; //現在なので必ず最速
					next_ship = i;
					next_room = ship[i].last_room+1;
					next_type = ARRIVE_ROOM;
					break;
				}

			}else{

				//★1つ前の船の1km手前に追いつく時刻
				if(i != 0 && ship[i].current_speed > ship[i-1].current_speed){

					tmp_time = current_time+((ship[i-1].current_loc-ship[i].current_loc)-1.0)/(double)(ship[i].current_speed-ship[i-1].current_speed);

					if(next_time > tmp_time){

						if(fabs(next_time-tmp_time) < EPS){
							next_time = current_time;
							break;
						}else{
							next_time = tmp_time;
						}

						next_ship = i;
						next_room = -1;
						next_type = CATCH_UP;
					}
				}

				if(i < ship_head || fabs(ship[i].current_speed) < EPS)continue;

				//★閘門に到達する時刻
				if(fabs(ship[i].current_loc-info[ship[i].last_room+1].loc) < EPS){

					tmp_time = current_time;

				}else{

					tmp_time = current_time+calc_time(i,ship[i].last_room+1);
				}

				if(ship[i].last_room+1 == num_room){ //次で川を出る場合

					if(next_time > tmp_time){
						next_time = tmp_time;
						next_ship = i;
						next_room = ship[i].last_room+1;
						next_type =  FINISH;
					}

				}else{

					if(next_time > tmp_time){
						next_time = tmp_time;
						next_ship = i;
						next_room = ship[i].last_room+1;
						next_type =  ARRIVE_ROOM;
					}
				}
			}
		}

		//閘門を走査
		for(int i = 0; i < num_room; i++){

			if(info[i].water != Moving)continue;

			if(next_time > info[i].move_end_time){

				next_time = info[i].move_end_time;
				next_room = i;
				next_ship = -1;

				if(info[i].is_east_higher){

					if(info[i].next_water == West){
						next_type = WATER_DOWN;
					}else{
						next_type = WATER_UP;
					}
				}else{ //西の方が水位が高い

					if(info[i].next_water == West){
						next_type = WATER_UP;
					}else{
						next_type = WATER_DOWN;
					}
				}
			}
		}

		Q.push(Data(next_time,next_ship,next_room,next_type));

		pre_time = current_time;
	}

	printf("%.10lf\n",ans);
}

int main(){

	while(true){
		scanf("%d %d %lf",&num_room,&num_ship,&LENGTH);
		if(num_room == 0)break;

		func();
	}

	return 0;
}