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

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

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

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

n.z = j
d.y = k
d.q = j
d.u = c
j.t = k
c.y = k
c.q = k
c.u = d
k.t = j
e.z = j
assert d.y.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

n.z = j
d.y = k
d.q = j
d.u = c
j.t = k
c.y = k
c.q = k
c.u = d
k.t = j
e.z = j
assert d.y.t.t.t.t.txt == "k"