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

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

class C:
    def __init__(self, txt: str):
        self.y: 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.s: B = None
        self.txt = txt

j = A("j")
l = B("l")
i = C("i")
g = D("g")
f = E("f")
m = C("m")

j.w = g
j.y = i
l.o = f
i.y = f
g.o = l
f.s = l
m.y = f
assert g.o.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: 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.s: B = None
        self.txt = txt

j = A("j")
l = B("l")
i = C("i")
g = D("g")
f = E("f")
m = C("m")

j.w = g
j.y = i
l.o = f
i.y = f
g.o = l
f.s = l
m.y = f
assert g.o.o.s.o.txt == "f"