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

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

n = A("n")
c = B("c")
h = C("h")
g = D("g")
i = C("i")
e = D("e")
l = C("l")
f = C("f")
b = C("b")

n.z = h
n.w = i
c.u = n
h.t = e
h.x = c
g.q = e
i.t = g
i.x = c
e.q = g
l.t = e
l.x = c
f.t = g
f.x = c
b.t = g
b.x = c
assert n.z.t.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

n = A("n")
c = B("c")
h = C("h")
g = D("g")
i = C("i")
e = D("e")
l = C("l")
f = C("f")
b = C("b")

n.z = h
n.w = i
c.u = n
h.t = e
h.x = c
g.q = e
i.t = g
i.x = c
e.q = g
l.t = e
l.x = c
f.t = g
f.x = c
b.t = g
b.x = c
assert n.z.t.q.q.q.txt == "g"