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

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

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

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

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

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

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

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

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