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

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

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

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

n = A("n")
j = B("j")
i = C("i")
l = D("l")
b = C("b")

n.u = j
n.x = b
j.s = i
j.w = n
j.x = l
i.q = n
i.w = n
i.p = n
l.q = n
b.q = n
b.w = n
b.p = n
assert n.x.p.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
i = C("i")
l = D("l")
b = C("b")

n.u = j
n.x = b
j.s = i
j.w = n
j.x = l
i.q = n
i.w = n
i.p = n
l.q = n
b.q = n
b.w = n
b.p = n
assert n.x.p.x.q.txt == "n"