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

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

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

k = A("k")
j = B("j")
f = C("f")
c = C("c")
g = A("g")
h = C("h")
b = C("b")
i = A("i")

k.p = h
j.x = h
j.t = c
f.y = g
f.z = j
f.p = i
c.y = i
c.p = i
c.z = j
g.p = b
h.y = i
h.z = j
h.p = g
b.y = i
b.p = i
b.z = j
i.p = c
assert g.p.p.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
f = C("f")
c = C("c")
g = A("g")
h = C("h")
b = C("b")
i = A("i")

k.p = h
j.x = h
j.t = c
f.y = g
f.z = j
f.p = i
c.y = i
c.p = i
c.z = j
g.p = b
h.y = i
h.z = j
h.p = g
b.y = i
b.p = i
b.z = j
i.p = c
assert g.p.p.p.y.p.txt == "c"