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

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

n = A("n")
l = B("l")
c = B("c")
k = B("k")
a = B("a")
g = A("g")
e = B("e")
b = B("b")
h = A("h")
j = B("j")

n.t = a
l.w = g
c.w = n
k.w = h
a.w = g
g.t = b
e.w = n
b.w = g
h.t = b
j.w = g
assert j.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

n = A("n")
l = B("l")
c = B("c")
k = B("k")
a = B("a")
g = A("g")
e = B("e")
b = B("b")
h = A("h")
j = B("j")

n.t = a
l.w = g
c.w = n
k.w = h
a.w = g
g.t = b
e.w = n
b.w = g
h.t = b
j.w = g
assert j.w.t.w.txt == "g"