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

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

g = A("g")
a = B("a")
e = B("e")
d = B("d")
c = A("c")
n = B("n")
k = A("k")
h = A("h")
f = A("f")

g.z = c
g.s = e
a.t = d
e.t = a
d.t = a
c.z = g
c.s = e
n.t = e
k.z = g
k.s = e
h.z = c
h.s = a
f.z = c
f.s = e
assert k.s.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: B = None
        self.txt = txt

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

g = A("g")
a = B("a")
e = B("e")
d = B("d")
c = A("c")
n = B("n")
k = A("k")
h = A("h")
f = A("f")

g.z = c
g.s = e
a.t = d
e.t = a
d.t = a
c.z = g
c.s = e
n.t = e
k.z = g
k.s = e
h.z = c
h.s = a
f.z = c
f.s = e
assert k.s.t.t.txt == "d"