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

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

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

e = A("e")
j = B("j")
f = C("f")
g = A("g")
c = A("c")

e.o = c
e.x = f
e.v = g
j.o = g
j.u = f
f.w = j
f.v = j
f.q = e
g.o = c
g.v = c
g.x = f
c.o = g
c.x = f
c.v = e
assert e.v.x.v.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.x: C = None
        self.v: A = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
f = C("f")
g = A("g")
c = A("c")

e.o = c
e.x = f
e.v = g
j.o = g
j.u = f
f.w = j
f.v = j
f.q = e
g.o = c
g.v = c
g.x = f
c.o = g
c.x = f
c.v = e
assert e.v.x.v.u.w.txt == "j"