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

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

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

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

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

a.u = b
b.v = n
b.u = l
b.w = l
b.o = a
n.y = b
n.o = b
l.s = n
l.w = a
l.u = a
assert a.u.v.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

a.u = b
b.v = n
b.u = l
b.w = l
b.o = a
n.y = b
n.o = b
l.s = n
l.w = a
l.u = a
assert a.u.v.o.w.txt == "l"