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

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

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

c = A("c")
f = B("f")
h = C("h")
m = C("m")
g = A("g")
k = B("k")

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

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

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

c = A("c")
f = B("f")
h = C("h")
m = C("m")
g = A("g")
k = B("k")

c.t = g
c.s = h
f.o = h
h.q = c
h.p = m
m.q = c
m.p = h
g.t = c
g.s = h
k.o = m
assert h.q.s.p.p.q.txt == "c"