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

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

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

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

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

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

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