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

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

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

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

i = A("i")
c = B("c")
h = C("h")
a = D("a")
g = C("g")
m = B("m")
k = A("k")

i.u = g
i.z = k
i.x = k
c.s = a
c.q = m
h.u = k
a.q = c
g.u = k
m.s = a
m.q = c
k.u = g
k.z = i
k.x = i
assert g.u.x.u.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: A = None
        self.x: A = None
        self.txt = txt

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

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

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

i = A("i")
c = B("c")
h = C("h")
a = D("a")
g = C("g")
m = B("m")
k = A("k")

i.u = g
i.z = k
i.x = k
c.s = a
c.q = m
h.u = k
a.q = c
g.u = k
m.s = a
m.q = c
k.u = g
k.z = i
k.x = i
assert g.u.x.u.u.z.u.txt == "g"