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

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

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

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

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

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

c.r = g
m.u = n
b.r = c
j.u = c
n.r = b
h.u = b
d.u = b
e.u = b
k.u = b
g.r = c
assert c.r.r.r.r.r.r.r.r.r.txt == "g"