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

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

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

g = A("g")
k = B("k")
m = C("m")
b = A("b")
c = A("c")
h = C("h")
j = C("j")
d = C("d")

g.p = k
g.z = m
g.s = c
k.v = c
k.s = b
m.y = b
m.v = d
m.t = k
b.p = k
b.z = h
b.s = c
c.p = k
c.z = d
c.s = b
h.y = g
h.v = j
h.t = k
j.y = b
j.v = m
j.t = k
d.y = b
d.v = h
d.t = k
assert m.t.v.z.y.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: C = None
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
m = C("m")
b = A("b")
c = A("c")
h = C("h")
j = C("j")
d = C("d")

g.p = k
g.z = m
g.s = c
k.v = c
k.s = b
m.y = b
m.v = d
m.t = k
b.p = k
b.z = h
b.s = c
c.p = k
c.z = d
c.s = b
h.y = g
h.v = j
h.t = k
j.y = b
j.v = m
j.t = k
d.y = b
d.v = h
d.t = k
assert m.t.v.z.y.z.v.txt == "j"