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

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

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

f = A("f")
i = B("i")
n = C("n")
c = B("c")
j = B("j")
d = C("d")
m = A("m")
a = B("a")
h = A("h")

f.y = d
f.t = d
i.w = n
i.o = m
n.p = j
c.w = n
c.o = h
j.w = d
j.o = f
d.p = c
m.y = n
m.t = d
a.w = d
a.o = f
h.y = d
h.t = d
assert m.y.p.o.t.p.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
n = C("n")
c = B("c")
j = B("j")
d = C("d")
m = A("m")
a = B("a")
h = A("h")

f.y = d
f.t = d
i.w = n
i.o = m
n.p = j
c.w = n
c.o = h
j.w = d
j.o = f
d.p = c
m.y = n
m.t = d
a.w = d
a.o = f
h.y = d
h.t = d
assert m.y.p.o.t.p.o.y.txt == "d"