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

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

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

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

a.t = m
d.x = m
c.y = k
k.y = n
h.x = j
j.x = h
e.t = j
m.x = h
n.y = c
assert d.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

a.t = m
d.x = m
c.y = k
k.y = n
h.x = j
j.x = h
e.t = j
m.x = h
n.y = c
assert d.x.x.x.x.x.x.x.x.txt == "h"