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

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

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

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

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

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

d.o = i
f.x = k
f.s = k
f.q = d
n.w = k
n.x = d
k.y = f
k.z = n
k.s = d
i.r = n
assert d.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

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

d.o = i
f.x = k
f.s = k
f.q = d
n.w = k
n.x = d
k.y = f
k.z = n
k.s = d
i.r = n
assert d.o.r.w.txt == "k"