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

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

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

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

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

c = A("c")
m = B("m")
k = C("k")
d = D("d")
f = E("f")

c.w = f
m.w = d
k.x = f
d.o = m
f.o = c
f.s = c
assert d.o.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

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

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

c = A("c")
m = B("m")
k = C("k")
d = D("d")
f = E("f")

c.w = f
m.w = d
k.x = f
d.o = m
f.o = c
f.s = c
assert d.o.w.o.w.txt == "d"