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

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

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

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

a = A("a")
h = B("h")
c = C("c")
k = D("k")

a.s = k
h.t = k
h.o = k
c.p = h
k.t = c
k.z = a
assert a.s.z.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
c = C("c")
k = D("k")

a.s = k
h.t = k
h.o = k
c.p = h
k.t = c
k.z = a
assert a.s.z.s.t.txt == "c"