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

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

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

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

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

l.p = i
f.z = b
h.v = f
b.u = l
b.y = f
j.v = f
i.u = l
i.y = f
assert h.v.z.y.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

l.p = i
f.z = b
h.v = f
b.u = l
b.y = f
j.v = f
i.u = l
i.y = f
assert h.v.z.y.z.u.txt == "l"