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

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

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

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

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

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

n.t = a
n.y = l
d.x = l
k.t = b
k.y = l
a.x = e
b.x = j
e.t = b
e.y = l
g.t = b
g.y = k
l.t = b
l.y = j
j.t = d
j.y = k
assert b.x.t.x.txt == "l"