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

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

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

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

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

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

c.x = n
k.t = e
d.t = c
l.t = n
g.x = n
i.t = c
b.t = c
h.t = e
n.x = g
e.x = g
assert g.x.x.x.x.x.x.x.txt == "n"