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

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

g = A("g")
d = B("d")
e = A("e")
c = A("c")
i = B("i")
m = A("m")
j = A("j")
k = A("k")

g.v = j
d.t = i
e.v = k
c.v = j
i.t = d
m.v = e
j.v = g
k.v = j
assert d.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

g = A("g")
d = B("d")
e = A("e")
c = A("c")
i = B("i")
m = A("m")
j = A("j")
k = A("k")

g.v = j
d.t = i
e.v = k
c.v = j
i.t = d
m.v = e
j.v = g
k.v = j
assert d.t.t.t.t.t.t.t.txt == "i"