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

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

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

g = A("g")
l = B("l")
c = C("c")
i = A("i")
k = B("k")
h = A("h")
j = C("j")

g.u = k
g.v = i
l.q = c
c.o = h
c.t = l
i.u = k
i.v = g
k.q = j
h.u = l
h.v = g
j.o = i
j.t = k
assert h.v.v.u.q.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: A = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
c = C("c")
i = A("i")
k = B("k")
h = A("h")
j = C("j")

g.u = k
g.v = i
l.q = c
c.o = h
c.t = l
i.u = k
i.v = g
k.q = j
h.u = l
h.v = g
j.o = i
j.t = k
assert h.v.v.u.q.o.v.txt == "g"