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

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

a = A("a")
c = B("c")
f = A("f")
e = A("e")
b = A("b")

a.q = b
a.t = c
c.y = e
f.q = a
f.t = c
e.q = a
e.t = c
b.q = f
b.t = c
assert f.q.q.q.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.txt = txt

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

a = A("a")
c = B("c")
f = A("f")
e = A("e")
b = A("b")

a.q = b
a.t = c
c.y = e
f.q = a
f.t = c
e.q = a
e.t = c
b.q = f
b.t = c
assert f.q.q.q.q.t.txt == "c"