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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: C = None
        self.u: D = None
        self.q: D = None
        self.txt = txt

f = A("f")
c = B("c")
m = C("m")
e = D("e")
g = E("g")

f.z = c
c.t = e
c.w = m
c.u = g
m.q = g
m.s = g
m.r = c
e.z = m
g.t = c
g.z = m
g.u = e
g.q = e
assert g.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: C = None
        self.u: D = None
        self.q: D = None
        self.txt = txt

f = A("f")
c = B("c")
m = C("m")
e = D("e")
g = E("g")

f.z = c
c.t = e
c.w = m
c.u = g
m.q = g
m.s = g
m.r = c
e.z = m
g.t = c
g.z = m
g.u = e
g.q = e
assert g.t.u.t.txt == "c"