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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: A = None
        self.s: E = None
        self.z: E = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
c = D("c")
m = E("m")

h.r = l
h.q = m
l.t = g
l.w = h
g.x = m
g.p = m
c.o = g
c.t = h
c.s = m
c.z = m
m.r = h
m.t = c
assert g.p.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: A = None
        self.s: E = None
        self.z: E = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
c = D("c")
m = E("m")

h.r = l
h.q = m
l.t = g
l.w = h
g.x = m
g.p = m
c.o = g
c.t = h
c.s = m
c.z = m
m.r = h
m.t = c
assert g.p.r.q.txt == "m"