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

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

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

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

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

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

e.y = k
m.u = c
m.q = f
d.u = g
d.q = k
f.u = n
f.q = m
n.y = d
i.y = k
k.u = g
k.q = f
g.y = d
c.y = f
assert c.y.q.q.u.y.u.y.u.txt == "g"