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

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

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

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

l = A("l")
f = B("f")
k = C("k")
j = D("j")

l.w = f
l.y = f
f.o = l
k.v = j
k.x = f
j.p = l
j.v = l
j.z = f
assert j.z.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
k = C("k")
j = D("j")

l.w = f
l.y = f
f.o = l
k.v = j
k.x = f
j.p = l
j.v = l
j.z = f
assert j.z.o.y.txt == "f"