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

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

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

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

h = A("h")
e = B("e")
k = C("k")
g = D("g")
i = D("i")
l = D("l")

h.x = g
h.w = g
e.w = k
e.s = k
e.r = k
k.z = e
k.s = e
k.o = e
g.x = l
g.v = i
i.x = g
i.v = l
l.x = g
l.v = i
assert e.s.s.s.o.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: D = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
k = C("k")
g = D("g")
i = D("i")
l = D("l")

h.x = g
h.w = g
e.w = k
e.s = k
e.r = k
k.z = e
k.s = e
k.o = e
g.x = l
g.v = i
i.x = g
i.v = l
l.x = g
l.v = i
assert e.s.s.s.o.r.s.txt == "e"