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

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

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

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

i = A("i")
a = B("a")
b = C("b")
f = D("f")
h = B("h")
l = D("l")
d = D("d")

i.o = d
a.w = i
b.s = h
f.v = d
f.x = i
h.w = i
l.v = d
l.x = i
d.v = l
d.x = i
assert l.v.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

i = A("i")
a = B("a")
b = C("b")
f = D("f")
h = B("h")
l = D("l")
d = D("d")

i.o = d
a.w = i
b.s = h
f.v = d
f.x = i
h.w = i
l.v = d
l.x = i
d.v = l
d.x = i
assert l.v.x.o.x.o.txt == "d"