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

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

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

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

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

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

j.v = a
i.u = n
e.u = b
g.v = a
b.v = i
n.v = e
k.v = e
f.v = i
a.u = g
assert g.v.u.v.u.v.u.txt == "g"