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

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

g = A("g")
l = B("l")
c = A("c")
f = B("f")

g.q = c
g.t = c
l.u = f
l.q = f
c.q = g
c.t = g
f.u = l
f.q = l
assert c.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: A = None
        self.txt = txt

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

g = A("g")
l = B("l")
c = A("c")
f = B("f")

g.q = c
g.t = c
l.u = f
l.q = f
c.q = g
c.t = g
f.u = l
f.q = l
assert c.q.q.q.q.txt == "c"