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

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

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

f = A("f")
n = B("n")
g = C("g")
l = C("l")
j = A("j")
c = B("c")
k = A("k")
h = A("h")

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

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

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

f = A("f")
n = B("n")
g = C("g")
l = C("l")
j = A("j")
c = B("c")
k = A("k")
h = A("h")

f.x = c
f.z = c
n.x = j
g.z = h
l.z = h
j.x = n
j.z = c
c.x = j
k.x = n
k.z = n
h.x = n
h.z = n
assert h.x.x.z.x.z.x.z.x.txt == "j"