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

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

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

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

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

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

b.z = d
i.t = n
n.z = k
k.t = b
g.z = l
d.t = g
a.z = d
l.t = b
assert d.t.z.t.z.t.z.t.z.txt == "d"