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

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

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

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

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

m.v = b
a.r = e
a.w = c
a.u = b
a.p = m
b.s = m
b.x = e
e.u = m
e.v = a
c.r = e
c.w = a
c.u = b
c.p = m
assert a.u.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

m.v = b
a.r = e
a.w = c
a.u = b
a.p = m
b.s = m
b.x = e
e.u = m
e.v = a
c.r = e
c.w = a
c.u = b
c.p = m
assert a.u.s.v.txt == "b"