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

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

j = A("j")
g = B("g")
i = B("i")
c = A("c")
f = B("f")
b = A("b")
m = B("m")
k = A("k")
l = A("l")
e = B("e")

j.y = f
g.s = b
g.u = j
i.s = c
i.u = k
c.y = m
f.s = l
f.u = c
b.y = g
m.s = l
m.u = c
k.y = i
l.y = f
e.s = l
e.u = k
assert g.u.y.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

j = A("j")
g = B("g")
i = B("i")
c = A("c")
f = B("f")
b = A("b")
m = B("m")
k = A("k")
l = A("l")
e = B("e")

j.y = f
g.s = b
g.u = j
i.s = c
i.u = k
c.y = m
f.s = l
f.u = c
b.y = g
m.s = l
m.u = c
k.y = i
l.y = f
e.s = l
e.u = k
assert g.u.y.s.y.s.txt == "l"