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

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

b = A("b")
a = B("a")
e = B("e")
d = A("d")
i = B("i")
g = A("g")
c = B("c")
j = A("j")

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

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

b = A("b")
a = B("a")
e = B("e")
d = A("d")
i = B("i")
g = A("g")
c = B("c")
j = A("j")

b.v = e
a.t = j
a.v = e
e.t = g
e.v = i
d.v = e
i.t = d
i.v = e
g.v = a
c.t = g
c.v = e
j.v = c
assert g.v.v.v.t.v.t.v.t.txt == "j"