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

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

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

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

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

n.o = m
b.v = a
b.w = m
b.x = n
a.r = m
a.x = m
a.s = b
m.u = n
assert n.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

n.o = m
b.v = a
b.w = m
b.x = n
a.r = m
a.x = m
a.s = b
m.u = n
assert n.o.u.o.u.txt == "n"