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

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

f = A("f")
m = B("m")
k = B("k")
i = B("i")
g = A("g")
d = A("d")
j = A("j")
e = B("e")

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

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

f = A("f")
m = B("m")
k = B("k")
i = B("i")
g = A("g")
d = A("d")
j = A("j")
e = B("e")

f.y = m
f.s = j
m.u = g
m.q = k
k.u = f
k.q = e
i.u = d
i.q = m
g.y = k
g.s = d
d.y = i
d.s = f
j.y = k
j.s = g
e.u = d
e.q = k
assert k.q.u.y.u.y.q.q.u.txt == "f"