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

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

a = A("a")
j = B("j")
f = A("f")
c = B("c")
g = A("g")
k = A("k")
b = A("b")
e = B("e")
n = A("n")

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

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

a = A("a")
j = B("j")
f = A("f")
c = B("c")
g = A("g")
k = A("k")
b = A("b")
e = B("e")
n = A("n")

a.u = j
j.s = a
f.u = c
c.s = g
g.u = c
k.u = e
b.u = e
e.s = n
n.u = c
assert f.u.s.u.s.txt == "g"