class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.p: C = None
        self.txt = txt

m = A("m")
k = B("k")
h = C("h")
g = C("g")
e = A("e")
c = A("c")
a = C("a")
i = B("i")
f = C("f")

m.o = i
k.t = m
k.q = g
h.y = g
h.x = i
h.p = f
g.y = a
g.p = a
g.x = i
e.o = k
c.o = i
a.y = f
a.p = f
a.x = k
i.t = m
i.q = f
f.y = h
f.x = i
f.p = a
assert k.t.o.t.o.t.o.q.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.p: C = None
        self.txt = txt

m = A("m")
k = B("k")
h = C("h")
g = C("g")
e = A("e")
c = A("c")
a = C("a")
i = B("i")
f = C("f")

m.o = i
k.t = m
k.q = g
h.y = g
h.x = i
h.p = f
g.y = a
g.p = a
g.x = i
e.o = k
c.o = i
a.y = f
a.p = f
a.x = k
i.t = m
i.q = f
f.y = h
f.x = i
f.p = a
assert k.t.o.t.o.t.o.q.y.y.txt == "g"