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

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

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

f = A("f")
j = B("j")
d = C("d")
b = A("b")
n = A("n")
e = C("e")
h = A("h")
k = B("k")

f.p = k
f.o = b
f.z = b
j.t = k
j.w = k
j.y = b
d.w = e
d.p = b
d.t = k
b.p = k
b.o = n
b.z = n
n.p = j
n.o = h
n.z = h
e.w = d
e.p = f
e.t = k
h.p = k
h.o = n
h.z = n
k.t = j
k.w = j
k.y = h
assert f.z.o.p.y.o.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: A = None
        self.z: A = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
d = C("d")
b = A("b")
n = A("n")
e = C("e")
h = A("h")
k = B("k")

f.p = k
f.o = b
f.z = b
j.t = k
j.w = k
j.y = b
d.w = e
d.p = b
d.t = k
b.p = k
b.o = n
b.z = n
n.p = j
n.o = h
n.z = h
e.w = d
e.p = f
e.t = k
h.p = k
h.o = n
h.z = n
k.t = j
k.w = j
k.y = h
assert f.z.o.p.y.o.z.p.txt == "k"