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

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

c = A("c")
m = B("m")
k = B("k")
b = B("b")
f = A("f")
g = A("g")
h = A("h")

c.t = m
c.q = b
m.y = f
m.s = k
k.y = f
k.s = b
b.y = f
b.s = m
f.t = b
f.q = k
g.t = b
g.q = k
h.t = b
h.q = k
assert c.q.s.y.q.y.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: B = None
        self.txt = txt

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

c = A("c")
m = B("m")
k = B("k")
b = B("b")
f = A("f")
g = A("g")
h = A("h")

c.t = m
c.q = b
m.y = f
m.s = k
k.y = f
k.s = b
b.y = f
b.s = m
f.t = b
f.q = k
g.t = b
g.q = k
h.t = b
h.q = k
assert c.q.s.y.q.y.t.s.txt == "m"