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

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

c = A("c")
j = B("j")
f = A("f")
m = B("m")
g = A("g")
h = B("h")
b = B("b")
n = B("n")
e = A("e")

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

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

c = A("c")
j = B("j")
f = A("f")
m = B("m")
g = A("g")
h = B("h")
b = B("b")
n = B("n")
e = A("e")

c.q = j
j.u = e
f.q = n
m.u = c
g.q = m
h.u = f
b.u = g
n.u = c
e.q = j
assert f.q.u.q.u.txt == "e"