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

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

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

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

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

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

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

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

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

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

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

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

c.r = l
c.x = n
c.z = m
m.v = h
h.z = m
h.q = m
h.s = m
h.p = l
n.x = m
n.s = h
n.r = c
g.p = m
l.r = c
l.x = n
l.z = m
assert h.p.x.x.v.p.z.txt == "m"