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

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

j = A("j")
g = B("g")
f = B("f")
e = A("e")
d = A("d")
l = A("l")
b = A("b")

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

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

j = A("j")
g = B("g")
f = B("f")
e = A("e")
d = A("d")
l = A("l")
b = A("b")

j.t = e
j.v = g
g.o = d
f.o = e
e.t = j
e.v = f
d.t = e
d.v = f
l.t = d
l.v = g
b.t = d
b.v = f
assert g.o.t.v.o.v.txt == "f"