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

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

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

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

c.y = j
c.s = f
n.y = l
n.q = l
h.z = l
f.y = h
f.s = c
j.z = n
l.y = n
l.q = n
assert f.y.z.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: A = None
        self.txt = txt

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

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

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

c.y = j
c.s = f
n.y = l
n.q = l
h.z = l
f.y = h
f.s = c
j.z = n
l.y = n
l.q = n
assert f.y.z.q.y.txt == "l"