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

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

m = A("m")
b = B("b")
k = B("k")
e = A("e")

m.t = e
m.y = e
b.q = e
b.t = e
k.q = m
k.t = e
e.t = m
e.y = m
assert k.q.y.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

m = A("m")
b = B("b")
k = B("k")
e = A("e")

m.t = e
m.y = e
b.q = e
b.t = e
k.q = m
k.t = e
e.t = m
e.y = m
assert k.q.y.y.t.txt == "e"