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

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

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

m = A("m")
i = B("i")
g = C("g")
n = C("n")
e = B("e")
j = B("j")

m.p = g
i.o = j
i.r = n
g.q = i
g.t = i
g.s = m
n.q = j
n.t = j
n.s = m
e.o = j
e.r = g
j.o = i
j.r = g
assert e.r.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
g = C("g")
n = C("n")
e = B("e")
j = B("j")

m.p = g
i.o = j
i.r = n
g.q = i
g.t = i
g.s = m
n.q = j
n.t = j
n.s = m
e.o = j
e.r = g
j.o = i
j.r = g
assert e.r.t.o.o.txt == "i"