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

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

j = A("j")
c = B("c")
m = A("m")
l = A("l")
n = A("n")
g = B("g")
k = B("k")
a = A("a")

j.t = g
j.v = l
c.v = g
m.t = c
m.v = l
l.t = k
l.v = j
n.t = g
n.v = m
g.v = c
k.v = c
a.t = k
a.v = m
assert c.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: A = None
        self.txt = txt

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

j = A("j")
c = B("c")
m = A("m")
l = A("l")
n = A("n")
g = B("g")
k = B("k")
a = A("a")

j.t = g
j.v = l
c.v = g
m.t = c
m.v = l
l.t = k
l.v = j
n.t = g
n.v = m
g.v = c
k.v = c
a.t = k
a.v = m
assert c.v.v.v.v.v.txt == "g"