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

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

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

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

n = A("n")
b = B("b")
k = C("k")
j = D("j")
f = A("f")

n.q = f
n.r = b
n.u = b
n.x = j
b.x = k
b.z = k
k.z = j
k.x = n
j.t = b
j.r = b
j.s = n
f.q = n
f.r = b
f.u = b
f.x = j
assert b.z.z.s.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.u: B = None
        self.x: D = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
k = C("k")
j = D("j")
f = A("f")

n.q = f
n.r = b
n.u = b
n.x = j
b.x = k
b.z = k
k.z = j
k.x = n
j.t = b
j.r = b
j.s = n
f.q = n
f.r = b
f.u = b
f.x = j
assert b.z.z.s.q.x.txt == "j"