module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
    string s,t;
    int a,b;
    string u;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ar = readln().strip().split();
		s = ar[0].to!string;
		t = ar[1].to!string;
		ar = readln().strip().split();
		a = ar[0].to!int;
		b = ar[1].to!int;
        u = readln().strip();
	}
}

struct Output
{
}

auto main2(Input* input)
{
    if (input.s == input.u)
        return (input.a - 1).to!string ~ " " ~ input.b.to!string;
    else
        return input.a.to!string ~ " " ~ (input.b - 1).to!string;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`red blue
3 4
red`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "2 4");
}

unittest // example2
{
	string example =
`red blue
5 5
blue`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == "5 4");
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}
