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

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

m = A("m")
g = B("g")
l = B("l")
d = A("d")
j = B("j")
a = B("a")
c = A("c")

m.s = j
m.t = l
g.y = l
l.y = g
d.s = j
d.t = a
j.y = l
a.y = l
c.s = j
c.t = j
assert j.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.txt = txt

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

m = A("m")
g = B("g")
l = B("l")
d = A("d")
j = B("j")
a = B("a")
c = A("c")

m.s = j
m.t = l
g.y = l
l.y = g
d.s = j
d.t = a
j.y = l
a.y = l
c.s = j
c.t = j
assert j.y.y.y.y.txt == "g"