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

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

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

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

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

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

e.r = i
e.x = g
g.t = e
g.s = e
i.x = e
i.w = e
i.z = g
i.t = g
i.y = d
k.o = d
d.o = k
assert g.t.x.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

e.r = i
e.x = g
g.t = e
g.s = e
i.x = e
i.w = e
i.z = g
i.t = g
i.y = d
k.o = d
d.o = k
assert g.t.x.s.r.txt == "i"