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

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

e = A("e")
i = B("i")
j = A("j")
g = A("g")
m = A("m")
c = A("c")
a = A("a")
h = B("h")

e.v = h
e.x = j
i.r = h
j.v = i
j.x = c
g.v = i
g.x = e
m.v = i
m.x = a
c.v = i
c.x = a
a.v = h
a.x = e
h.r = i
assert i.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
j = A("j")
g = A("g")
m = A("m")
c = A("c")
a = A("a")
h = B("h")

e.v = h
e.x = j
i.r = h
j.v = i
j.x = c
g.v = i
g.x = e
m.v = i
m.x = a
c.v = i
c.x = a
a.v = h
a.x = e
h.r = i
assert i.r.r.r.r.r.r.r.r.txt == "i"