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

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

n = A("n")
l = B("l")
c = B("c")
a = B("a")
j = A("j")

n.s = j
n.w = j
l.y = c
c.y = a
a.y = l
j.s = n
j.w = n
assert l.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.txt = txt

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

n = A("n")
l = B("l")
c = B("c")
a = B("a")
j = A("j")

n.s = j
n.w = j
l.y = c
c.y = a
a.y = l
j.s = n
j.w = n
assert l.y.y.y.y.txt == "c"