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

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

b = A("b")
a = B("a")
g = A("g")
e = A("e")
j = B("j")
f = B("f")
n = B("n")
i = B("i")

b.v = e
b.o = j
a.t = g
a.z = g
g.v = b
g.o = a
e.v = g
e.o = a
j.t = b
j.z = g
f.t = b
f.z = g
n.t = b
n.z = e
i.t = g
i.z = b
assert b.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: B = None
        self.txt = txt

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

b = A("b")
a = B("a")
g = A("g")
e = A("e")
j = B("j")
f = B("f")
n = B("n")
i = B("i")

b.v = e
b.o = j
a.t = g
a.z = g
g.v = b
g.o = a
e.v = g
e.o = a
j.t = b
j.z = g
f.t = b
f.z = g
n.t = b
n.z = e
i.t = g
i.z = b
assert b.v.v.v.v.v.txt == "g"