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

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

i = A("i")
k = B("k")
h = B("h")
l = A("l")
g = A("g")
e = B("e")
m = B("m")
n = B("n")

i.t = g
i.q = g
k.u = l
k.t = h
h.u = g
h.t = n
l.t = i
l.q = i
g.t = l
g.q = l
e.u = i
e.t = m
m.u = g
m.t = h
n.u = i
n.t = m
assert k.u.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.txt = txt

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

i = A("i")
k = B("k")
h = B("h")
l = A("l")
g = A("g")
e = B("e")
m = B("m")
n = B("n")

i.t = g
i.q = g
k.u = l
k.t = h
h.u = g
h.t = n
l.t = i
l.q = i
g.t = l
g.q = l
e.u = i
e.t = m
m.u = g
m.t = h
n.u = i
n.t = m
assert k.u.t.q.txt == "g"