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

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

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

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

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

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

i.t = c
i.r = e
c.r = h
c.q = h
e.t = c
e.r = h
h.t = l
h.r = k
g.r = e
g.q = e
l.r = i
l.q = h
k.t = l
k.r = e
d.r = k
d.q = k
n.r = i
n.q = i
assert h.r.r.t.r.r.t.q.txt == "h"