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;

double pow(double x, int n) {
    if (n == 0) return 1.0;
    if (n % 2 == 1) return pow(x, n - 1) * x;
    return pow(x * x, n / 2);
}
 
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 = 0.0;
        foreach (k; 0 .. 1440) {
            ct = cast(int)k;
            cw = 0;
            int C = 0;
            foreach (_; 0 .. m) {
                //writeln([ct, cw]);
                if (check) {
                    C += n;
                }
                ct += t;
                if (ct >= 1440) {
                    ct -= 1440;
                    cw = (cw + 1) % 7;
                }
            }
            Ans = max(Ans, 1.0 - pow(1.0 - 1.0 / p, C));
        }
        writefln("%.10f", Ans);
    }

    while (input) solve;
}