#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

const int limit = 60 * 24 * 7;  // 開始時は0〜limit分の決め方がある
int s, n, t, p, m;
string weekday, my_time;
const string week[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

bool InLenge(int time)
{
    int w = time % (7 * 24 * 60);
    int h = time % (24 * 60);
    bool res = false;

    if (weekday == "All")
        res = true;
    else {
        for (int i = 0; i < 7; ++i)
            if (weekday == week[i]) {
                if (i * 24 * 60 <= w && w < (i + 1) * 24 * 60)
                    res = true;
                break;
            }
    }
    if (!res)
        return false;

    res = false;
    if (my_time == "All")
        res = true;
    else if (my_time == "Day" && 6 * 60 <= h && h < 18 * 60)
        res = true;
    if (my_time == "Night" && ((0 <= h && h < 6 * 60) || (18 * 60 <= h && h < 24 * 60)))
        res = true;

    return res;
}

int Count(int st)
{
    int res = 0;
    for (int i = 0; i < m; ++i) {
        if (InLenge(st) && InLenge(st + s)) {
            ++res;
        }
        st += t;
    }
    return res;
}

int main()
{
    while (true) {
        // Input
        cin >> s >> n >> t >> weekday >> my_time >> p >> m;
        if (s == 0 && n == 0 && t == 0 && p == 0 && m == 0 &&
            weekday == "None" && my_time == "None")
            break;

        int max_cnt = 0;
        for (int i = 0; i < limit; ++i)
            max_cnt = max(max_cnt, Count(i));

        printf("%.10f\n", 1.0 - pow(1.0 - 1.0 / p, n * max_cnt));
    }

    return 0;
}