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

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

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

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

k.t = j
k.q = e
h.o = f
h.q = f
c.p = i
j.t = k
j.q = c
i.o = f
i.q = f
f.o = h
f.q = i
e.p = i
assert k.q.p.o.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: C = None
        self.txt = txt

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

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

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

k.t = j
k.q = e
h.o = f
h.q = f
c.p = i
j.t = k
j.q = c
i.o = f
i.q = f
f.o = h
f.q = i
e.p = i
assert k.q.p.o.q.q.txt == "f"