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

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

g = A("g")
c = B("c")
f = B("f")
l = A("l")
m = B("m")
n = B("n")
a = A("a")

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

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

g = A("g")
c = B("c")
f = B("f")
l = A("l")
m = B("m")
n = B("n")
a = A("a")

g.s = l
c.s = f
c.y = n
f.s = m
f.y = m
l.s = a
m.s = n
m.y = c
n.s = c
n.y = m
a.s = l
assert f.y.y.s.s.s.s.y.txt == "n"