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

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

m = A("m")
b = B("b")
n = B("n")
c = A("c")
e = B("e")
f = A("f")
i = A("i")
h = B("h")
a = B("a")

m.v = f
m.t = e
b.v = n
b.r = m
n.v = b
n.r = c
c.v = m
c.t = h
e.v = h
e.r = f
f.v = i
f.t = a
i.v = f
i.t = n
h.v = n
h.r = m
a.v = b
a.r = i
assert c.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

m = A("m")
b = B("b")
n = B("n")
c = A("c")
e = B("e")
f = A("f")
i = A("i")
h = B("h")
a = B("a")

m.v = f
m.t = e
b.v = n
b.r = m
n.v = b
n.r = c
c.v = m
c.t = h
e.v = h
e.r = f
f.v = i
f.t = a
i.v = f
i.t = n
h.v = n
h.r = m
a.v = b
a.r = i
assert c.v.v.v.txt == "i"