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

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

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

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

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

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

g.w = h
f.t = n
h.q = n
h.t = g
m.x = n
m.p = n
n.t = m
n.r = m
n.w = g
n.z = h
assert h.t.w.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

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

g.w = h
f.t = n
h.q = n
h.t = g
m.x = n
m.p = n
n.t = m
n.r = m
n.w = g
n.z = h
assert h.t.w.q.z.q.txt == "n"