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

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

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

e.t = a
e.s = l
f.x = e
h.x = a
g.x = e
a.t = e
a.s = f
j.x = a
l.x = d
d.t = a
d.s = h
assert f.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: B = None
        self.txt = txt

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

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

e.t = a
e.s = l
f.x = e
h.x = a
g.x = e
a.t = e
a.s = f
j.x = a
l.x = d
d.t = a
d.s = h
assert f.x.t.s.txt == "f"