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

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

a = A("a")
h = B("h")
n = A("n")
i = B("i")
g = B("g")
f = B("f")
e = A("e")

a.y = f
h.s = e
h.t = f
n.y = g
i.s = a
i.t = f
g.s = a
g.t = f
f.s = e
f.t = g
e.y = g
assert h.s.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
n = A("n")
i = B("i")
g = B("g")
f = B("f")
e = A("e")

a.y = f
h.s = e
h.t = f
n.y = g
i.s = a
i.t = f
g.s = a
g.t = f
f.s = e
f.t = g
e.y = g
assert h.s.y.t.txt == "f"