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

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

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

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

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

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

i.t = c
i.r = k
k.x = g
k.t = h
n.x = g
n.t = k
g.x = n
g.t = h
c.t = i
c.r = g
h.x = n
h.t = n
assert k.t.t.x.t.t.txt == "n"