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

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.s: C = None
        self.v: A = None
        self.txt = txt

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

k.s = j
k.r = j
k.o = h
h.s = k
f.r = h
f.p = j
j.q = h
j.w = h
j.s = f
j.v = k
assert h.s.o.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: B = None
        self.r: D = 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.r: B = None
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.s: C = None
        self.v: A = None
        self.txt = txt

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

k.s = j
k.r = j
k.o = h
h.s = k
f.r = h
f.p = j
j.q = h
j.w = h
j.s = f
j.v = k
assert h.s.o.s.s.txt == "j"