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

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

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

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

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

d = A("d")
f = B("f")
k = C("k")
e = D("e")
i = E("i")

d.r = i
d.t = e
f.s = e
k.t = d
k.x = d
k.w = e
e.w = k
i.p = f
i.t = f
i.s = f
assert f.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.t: D = None
        self.txt = txt

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

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

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

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

d = A("d")
f = B("f")
k = C("k")
e = D("e")
i = E("i")

d.r = i
d.t = e
f.s = e
k.t = d
k.x = d
k.w = e
e.w = k
i.p = f
i.t = f
i.s = f
assert f.s.w.w.txt == "e"