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

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

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

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

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

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

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

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

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

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

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

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

j.p = a
j.w = m
m.q = c
m.t = c
m.x = j
m.w = a
c.r = m
c.z = m
h.r = j
h.s = c
a.z = m
assert h.r.w.w.txt == "a"