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

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

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

i = A("i")
g = B("g")
b = C("b")
d = B("d")
e = B("e")
f = B("f")

i.t = b
i.x = g
g.o = f
g.w = b
g.u = b
b.q = i
b.w = i
d.o = f
d.w = b
d.u = b
e.o = g
e.w = b
e.u = b
f.o = g
f.w = b
f.u = b
assert b.w.t.q.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: B = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
b = C("b")
d = B("d")
e = B("e")
f = B("f")

i.t = b
i.x = g
g.o = f
g.w = b
g.u = b
b.q = i
b.w = i
d.o = f
d.w = b
d.u = b
e.o = g
e.w = b
e.u = b
f.o = g
f.w = b
f.u = b
assert b.w.t.q.t.w.txt == "i"