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

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

h = A("h")
k = B("k")
c = A("c")
n = A("n")

h.s = k
h.y = k
k.w = c
c.s = k
c.y = k
n.s = k
n.y = k
assert n.y.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
c = A("c")
n = A("n")

h.s = k
h.y = k
k.w = c
c.s = k
c.y = k
n.s = k
n.y = k
assert n.y.w.s.w.txt == "c"