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

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

k = A("k")
a = B("a")
b = C("b")
f = D("f")

k.o = b
a.z = f
b.z = a
b.s = f
f.v = b
f.p = a
assert b.z.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = 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.z: B = None
        self.s: D = None
        self.txt = txt

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

k = A("k")
a = B("a")
b = C("b")
f = D("f")

k.o = b
a.z = f
b.z = a
b.s = f
f.v = b
f.p = a
assert b.z.z.p.txt == "a"