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

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

h = A("h")
a = B("a")
g = A("g")
e = B("e")
b = A("b")

h.y = a
h.s = a
a.w = g
a.v = e
g.y = a
g.s = a
e.w = g
e.v = a
b.y = a
b.s = e
assert h.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: B = None
        self.txt = txt

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

h = A("h")
a = B("a")
g = A("g")
e = B("e")
b = A("b")

h.y = a
h.s = a
a.w = g
a.v = e
g.y = a
g.s = a
e.w = g
e.v = a
b.y = a
b.s = e
assert h.y.w.y.txt == "a"