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

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

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

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

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

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

g.w = k
g.t = k
j.x = g
k.x = n
c.w = j
c.t = a
a.x = g
n.w = k
n.t = k
h.x = g
assert h.x.t.x.w.x.t.x.txt == "n"