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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.y: E = None
        self.txt = txt

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

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

b.u = n
b.p = d
b.x = c
b.o = c
n.r = b
d.y = m
c.p = d
c.v = d
c.y = m
m.o = n
assert d.y.o.r.u.r.txt == "b"