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

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

f = A("f")
d = B("d")
c = A("c")
b = B("b")
i = A("i")
k = A("k")
j = B("j")
n = B("n")
e = A("e")
g = B("g")

f.x = n
d.z = k
d.t = c
c.x = d
b.z = c
b.t = k
i.x = b
k.x = j
j.z = k
j.t = e
n.z = k
n.t = i
e.x = d
g.z = e
g.t = f
assert j.t.x.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
c = A("c")
b = B("b")
i = A("i")
k = A("k")
j = B("j")
n = B("n")
e = A("e")
g = B("g")

f.x = n
d.z = k
d.t = c
c.x = d
b.z = c
b.t = k
i.x = b
k.x = j
j.z = k
j.t = e
n.z = k
n.t = i
e.x = d
g.z = e
g.t = f
assert j.t.x.z.x.z.x.txt == "j"