import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int s, n, t, p, m;
    string weekday, time;

    bool input() {
        readf("%d %d %d %s %s %d %d\n", &s, &n, &t, &weekday, &time, &p, &m);
        //writeln([s, n, t, p, m]);
        //writeln([weekday, time]);
        return (weekday != "None");
    }

    void solve() {
        const W = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
        int cw = 0;
        int ct = 0;
        bool check() {
            if (weekday != "All" && W[cw] != "Sun") return false;
            if (time == "All") return true;
            if (time == "Day" && 360 <= ct && ct + s < 1080) return true;
            if (time == "Night" && (0 <= ct && ct + s < 360 || 1080 <= ct && ct + s < 1440)) return true;
            return false;
        }
        double Ans = 1.0;
        while (m--) {
            //writeln([ct, cw]);
            if (check) {
                foreach (j; 0 .. n) {
                    Ans *= (1.0 - 1.0 / p);
                }
            }
            ct += t;
            if (ct >= 1440) {
                ct -= 1440;
                cw = (cw + 1) % 7;
            }
        }
        writefln("%.10f", 1.0 - Ans);
    }

    while (input) solve;
}