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

k = A("k")
a = B("a")
h = A("h")
b = B("b")
j = A("j")
c = B("c")
e = B("e")
g = A("g")

k.t = j
k.v = e
a.o = g
h.t = j
h.v = e
b.o = j
j.t = g
j.v = e
c.o = h
e.o = k
g.t = h
g.v = e
assert k.t.v.o.t.t.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

k = A("k")
a = B("a")
h = A("h")
b = B("b")
j = A("j")
c = B("c")
e = B("e")
g = A("g")

k.t = j
k.v = e
a.o = g
h.t = j
h.v = e
b.o = j
j.t = g
j.v = e
c.o = h
e.o = k
g.t = h
g.v = e
assert k.t.v.o.t.t.txt == "g"