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

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

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

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

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

l.p = d
i.w = f
i.u = d
d.z = i
f.t = l
f.y = d
assert i.w.y.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

l.p = d
i.w = f
i.u = d
d.z = i
f.t = l
f.y = d
assert i.w.y.z.u.txt == "d"