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

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

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

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

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

b.z = k
b.q = m
n.t = k
n.x = d
i.q = b
i.w = d
d.u = g
k.t = n
k.x = d
g.t = k
g.x = d
m.q = b
m.w = d
assert b.q.q.z.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: C = None
        self.txt = txt

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

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

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

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

b.z = k
b.q = m
n.t = k
n.x = d
i.q = b
i.w = d
d.u = g
k.t = n
k.x = d
g.t = k
g.x = d
m.q = b
m.w = d
assert b.q.q.z.x.u.txt == "g"