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

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

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

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

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

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

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

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

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