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

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

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

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

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

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

m.q = h
c.y = m
c.z = m
c.p = j
c.q = k
c.x = k
k.v = h
j.o = c
j.u = k
j.v = m
h.q = c
h.v = c
h.p = m
assert m.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

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

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

m.q = h
c.y = m
c.z = m
c.p = j
c.q = k
c.x = k
k.v = h
j.o = c
j.u = k
j.v = m
h.q = c
h.v = c
h.p = m
assert m.q.p.q.txt == "h"