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

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

g = A("g")
b = B("b")
k = B("k")
e = A("e")
m = B("m")
i = B("i")

g.s = e
g.y = e
b.t = e
b.q = e
k.t = g
k.q = e
e.s = g
e.y = g
m.t = g
m.q = g
i.t = g
i.q = g
assert b.t.s.y.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
k = B("k")
e = A("e")
m = B("m")
i = B("i")

g.s = e
g.y = e
b.t = e
b.q = e
k.t = g
k.q = e
e.s = g
e.y = g
m.t = g
m.q = g
i.t = g
i.q = g
assert b.t.s.y.s.y.s.txt == "g"