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

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

c = A("c")
a = B("a")
e = A("e")
f = A("f")
h = B("h")

c.t = h
a.v = e
a.t = h
e.t = a
f.t = h
h.v = e
h.t = a
assert h.t.t.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

c = A("c")
a = B("a")
e = A("e")
f = A("f")
h = B("h")

c.t = h
a.v = e
a.t = h
e.t = a
f.t = h
h.v = e
h.t = a
assert h.t.t.v.t.t.txt == "h"