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

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

l = A("l")
i = B("i")
e = C("e")
f = D("f")
g = D("g")
c = A("c")

l.w = f
l.r = i
l.y = e
i.s = f
e.t = i
e.o = i
f.x = g
g.x = f
c.w = f
c.r = i
c.y = e
assert e.o.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.r: B = None
        self.y: C = 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: B = None
        self.o: B = None
        self.txt = txt

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

l = A("l")
i = B("i")
e = C("e")
f = D("f")
g = D("g")
c = A("c")

l.w = f
l.r = i
l.y = e
i.s = f
e.t = i
e.o = i
f.x = g
g.x = f
c.w = f
c.r = i
c.y = e
assert e.o.s.x.x.txt == "f"