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

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

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

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

c = A("c")
n = B("n")
m = C("m")
a = D("a")
b = C("b")

c.v = n
c.z = n
c.t = b
c.u = a
n.y = m
n.s = a
n.p = c
m.w = a
m.x = a
a.o = n
b.w = a
b.x = a
assert b.x.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.t: C = None
        self.u: D = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
m = C("m")
a = D("a")
b = C("b")

c.v = n
c.z = n
c.t = b
c.u = a
n.y = m
n.s = a
n.p = c
m.w = a
m.x = a
a.o = n
b.w = a
b.x = a
assert b.x.o.s.o.txt == "n"