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

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

f = A("f")
h = B("h")
g = A("g")
l = A("l")
m = B("m")
d = A("d")
e = A("e")
n = A("n")
i = A("i")

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

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

f = A("f")
h = B("h")
g = A("g")
l = A("l")
m = B("m")
d = A("d")
e = A("e")
n = A("n")
i = A("i")

f.q = h
f.u = h
h.q = i
g.q = m
g.u = h
l.q = h
l.u = m
m.q = g
d.q = h
d.u = h
e.q = m
e.u = h
n.q = m
n.u = h
i.q = m
i.u = h
assert f.u.q.q.q.q.q.q.q.q.txt == "m"