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

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

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

n = A("n")
m = B("m")
k = C("k")
j = B("j")
b = C("b")
d = C("d")
i = C("i")

n.t = b
m.t = j
m.x = n
m.y = b
k.u = b
j.t = m
j.x = n
j.y = i
b.u = d
d.u = k
i.u = k
assert i.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
k = C("k")
j = B("j")
b = C("b")
d = C("d")
i = C("i")

n.t = b
m.t = j
m.x = n
m.y = b
k.u = b
j.t = m
j.x = n
j.y = i
b.u = d
d.u = k
i.u = k
assert i.u.u.u.u.u.u.u.txt == "k"