class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: A = 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.u: C = None
        self.txt = txt

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

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

i.z = n
i.s = g
c.u = i
b.u = d
j.s = d
j.t = i
j.u = i
j.q = m
n.u = g
d.u = b
g.z = n
g.s = i
m.s = d
m.t = i
m.u = g
m.q = j
assert n.u.s.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: A = 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.u: C = None
        self.txt = txt

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

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

i.z = n
i.s = g
c.u = i
b.u = d
j.s = d
j.t = i
j.u = i
j.q = m
n.u = g
d.u = b
g.z = n
g.s = i
m.s = d
m.t = i
m.u = g
m.q = j
assert n.u.s.z.u.txt == "g"