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

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

j = A("j")
m = B("m")
b = A("b")
i = A("i")
h = A("h")
d = B("d")
n = B("n")
g = A("g")
c = A("c")
l = B("l")

j.v = h
m.t = g
b.v = i
i.v = b
h.v = g
d.t = i
n.t = h
g.v = j
c.v = i
l.t = b
assert i.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.t: A = None
        self.txt = txt

j = A("j")
m = B("m")
b = A("b")
i = A("i")
h = A("h")
d = B("d")
n = B("n")
g = A("g")
c = A("c")
l = B("l")

j.v = h
m.t = g
b.v = i
i.v = b
h.v = g
d.t = i
n.t = h
g.v = j
c.v = i
l.t = b
assert i.v.v.v.v.v.v.txt == "i"