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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.s: B = None
        self.txt = txt

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

a = A("a")
n = B("n")
l = C("l")
i = D("i")

a.r = n
a.w = n
a.x = n
a.p = l
n.q = l
n.u = i
n.z = i
l.o = n
l.s = n
l.y = a
i.t = a
i.o = n
assert a.x.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: C = None
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.s: B = None
        self.txt = txt

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

a = A("a")
n = B("n")
l = C("l")
i = D("i")

a.r = n
a.w = n
a.x = n
a.p = l
n.q = l
n.u = i
n.z = i
l.o = n
l.s = n
l.y = a
i.t = a
i.o = n
assert a.x.z.t.txt == "a"