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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

l.w = a
a.p = l
f.t = a
f.p = l
h.v = l
h.z = l
assert f.p.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

l.w = a
a.p = l
f.t = a
f.p = l
h.v = l
h.z = l
assert f.p.w.p.w.txt == "a"