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

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

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

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

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

f = A("f")
e = B("e")
b = C("b")
i = D("i")
g = E("g")

f.w = g
e.z = f
b.s = i
b.y = i
b.r = g
b.w = f
i.t = g
i.u = e
i.p = b
g.z = b
g.y = b
g.r = e
g.t = e
assert f.w.t.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

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

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

f = A("f")
e = B("e")
b = C("b")
i = D("i")
g = E("g")

f.w = g
e.z = f
b.s = i
b.y = i
b.r = g
b.w = f
i.t = g
i.u = e
i.p = b
g.z = b
g.y = b
g.r = e
g.t = e
assert f.w.t.z.w.txt == "g"