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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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