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

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

m = A("m")
k = B("k")
c = A("c")
a = B("a")
b = B("b")
d = A("d")
n = A("n")
f = A("f")

m.v = f
k.u = a
c.v = f
a.u = b
b.u = a
d.v = c
n.v = c
f.v = c
assert c.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

m = A("m")
k = B("k")
c = A("c")
a = B("a")
b = B("b")
d = A("d")
n = A("n")
f = A("f")

m.v = f
k.u = a
c.v = f
a.u = b
b.u = a
d.v = c
n.v = c
f.v = c
assert c.v.v.v.v.v.v.v.v.txt == "c"