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

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

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

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

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

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

a.v = g
m.v = a
m.x = b
g.p = a
d.r = b
d.o = m
b.u = g
b.v = g
b.o = m
b.z = d
b.r = c
c.u = g
c.v = g
c.o = m
c.z = d
c.r = b
assert d.r.o.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

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

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