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

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

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

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

e.p = g
g.q = h
g.p = h
g.w = i
j.o = g
j.z = f
h.q = i
h.p = g
h.w = g
f.p = i
i.q = h
i.p = g
i.w = g
k.p = g
assert i.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

e.p = g
g.q = h
g.p = h
g.w = i
j.o = g
j.z = f
h.q = i
h.p = g
h.w = g
f.p = i
i.q = h
i.p = g
i.w = g
k.p = g
assert i.p.q.p.txt == "g"