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

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

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

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

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

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

c.q = k
c.y = b
k.s = c
f.q = l
f.y = b
g.q = l
g.y = c
b.q = l
b.y = e
e.q = k
e.y = b
l.s = f
assert e.y.y.y.q.s.y.q.txt == "l"