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

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

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

f = A("f")
g = B("g")
c = C("c")
i = A("i")
d = C("d")

f.o = i
f.w = g
f.q = g
g.t = i
c.v = i
c.t = i
c.s = i
i.o = f
i.w = g
i.q = g
d.v = f
d.t = i
d.s = i
assert g.t.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: B = None
        self.q: B = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
c = C("c")
i = A("i")
d = C("d")

f.o = i
f.w = g
f.q = g
g.t = i
c.v = i
c.t = i
c.s = i
i.o = f
i.w = g
i.q = g
d.v = f
d.t = i
d.s = i
assert g.t.o.o.o.o.txt == "i"