#include <iostream>
#include <cstdio>
//#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
//#include <stack>
//#include <limits>
#include <sstream>
//#include <functional>
using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define fmax(a, b) (a < b? b : a)
#define fmin(a, b) (a > b? b : a)
#define fabs(a) (a < 0? -a : a)
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const int weight[] = {0,1,10,100,1000,10000,100000,1000000,10000000};
//priority_queue< int, vector<int>, greater<int> > q;

void doIt(){
  int s, n, t, p, m, npos = 0;
  string weekday, time;
  P stages[102], black[10000];
  while(true){
	npos = 0;
	cin >> s >> n >> t >> weekday >> time >> p >> m;
	if(s == 0 && n == 0) break;
	rep(i, 0, m){
	  stages[i] = P(i*t, i*t + s);
	}
	int start = 0;
	if(time == "All"){
	  //別処理
	  if(weekday == "All"){
		black[npos] = P(start, start + 110000);
		npos++;
	  }
	  else{
		while(start <= 110000){
		  black[npos] = P(start, start + 1440);
		  start += 10080;
		  npos++;
		}
	  }
	}
	else if(time == "Day"){
	  while(start <= 110000){
		black[npos++] = P(start, start + 720);
		if(weekday == "All"){
		  //start++;
		  start += 1440;
		}
		else start += 10080;
	  }
	}
	//Night
	else{
	  if(weekday == "All"){
		while(start <= 110000){
		  black[npos++] = P(start, start + 720);
		  start += 1440;
		}
	  }
	  else{
		while(start <= 110000){
		  black[npos++] = P(start,start + 360);
		  start += 360;
		  start += 720;
		  black[npos++] = P(start,start + 360);
		  start += 360;
		  start += 10080 - 1440;

		}

	  }

	}
	int aans = 0;
	rep(i, 0, t+1){
	  int spos = 0, bpos = 0, sum = 0;
	  while(spos < m && bpos < npos){
		//int tmp = min(stages[spos].second, black[bpos].second + i) - max(stages[spos].first, black[bpos].first + i);;
		if(stages[spos].first + i >= black[bpos].first && stages[spos].second + i < black[bpos].second/*tmp <= 0*/){
		  //cout << stages[spos].first << ", " << black[bpos].first + i << ", " << stages[spos].second << ", " << black[bpos].second + i << endl;
		  sum++;
		  if(spos == m-1) bpos++;
		  else spos++;
		  //sum += stages[spos].second - stages[spos].first;
		}
		else{
		  if(stages[spos].second + i < black[bpos].second){
			if(spos == m-1) bpos++;
			else spos++;
		  }
		  else{
			if(bpos == npos-1) spos++;
			else bpos++;
		  }
		}
	  }
	  //if(i == 60) cout << aans << endl;
	  //if(aans == 12) cout << "i = " << i << endl;
	  aans = max(aans, sum);
	}
	//cout << "aans = " << aans << endl;
	//aans = 13;
	double tt = ((double)p - 1.0) / p;
	double pt = 1.0 - pow(tt,aans*n);

	//printf("%.9f\n", (aans)*tt / (double)(m) );
	printf("%.11f\n", pt );
  }
}

int main() {
  doIt();
  return 0;
}

Measured memory_bytes: 1348