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

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

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

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

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

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

k.q = e
j.s = f
j.y = k
m.s = e
m.y = k
f.s = e
f.y = l
d.q = e
l.q = e
e.s = f
e.y = d
assert d.q.s.y.q.y.q.txt == "e"