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

class B:
    def __init__(self, txt: str):
        self.s: A = 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.s: B = None
        self.x: B = None
        self.txt = txt

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

l.u = f
f.s = l
d.v = f
h.s = f
h.x = f
assert h.x.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = 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.s: B = None
        self.x: B = None
        self.txt = txt

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

l.u = f
f.s = l
d.v = f
h.s = f
h.x = f
assert h.x.s.u.txt == "f"