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

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

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

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

i = A("i")
m = B("m")
j = C("j")
c = D("c")
n = C("n")
a = B("a")
g = A("g")
h = A("h")
l = D("l")

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

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

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

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

i = A("i")
m = B("m")
j = C("j")
c = D("c")
n = C("n")
a = B("a")
g = A("g")
h = A("h")
l = D("l")

i.q = j
m.u = j
m.p = g
j.s = c
j.z = a
c.z = n
c.x = j
c.o = j
c.t = i
n.s = c
n.z = m
a.u = j
a.p = i
g.q = j
h.q = j
l.z = j
l.x = j
l.o = n
l.t = g
assert a.p.q.z.p.txt == "i"