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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

a = A("a")
c = B("c")
h = C("h")
m = D("m")
k = E("k")

a.v = c
c.o = a
c.w = a
h.r = c
h.x = c
h.o = c
h.q = m
h.u = m
m.y = a
k.z = a
assert m.y.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

a = A("a")
c = B("c")
h = C("h")
m = D("m")
k = E("k")

a.v = c
c.o = a
c.w = a
h.r = c
h.x = c
h.o = c
h.q = m
h.u = m
m.y = a
k.z = a
assert m.y.v.o.v.txt == "c"