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

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

c = A("c")
g = B("g")
h = B("h")

c.y = g
c.w = h
g.t = h
g.y = c
h.t = g
h.y = c
assert h.t.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

c = A("c")
g = B("g")
h = B("h")

c.y = g
c.w = h
g.t = h
g.y = c
h.t = g
h.y = c
assert h.t.y.w.txt == "h"