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

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

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

a = A("a")
g = B("g")
l = C("l")
c = C("c")
d = A("d")
m = A("m")
i = A("i")
e = B("e")
f = A("f")

a.r = g
a.o = l
a.q = l
g.v = e
l.x = e
l.r = e
l.v = c
c.x = e
c.r = e
c.v = l
d.r = e
d.o = c
d.q = c
m.r = e
m.o = c
m.q = c
i.r = g
i.o = c
i.q = l
e.v = g
f.r = e
f.o = c
f.q = l
assert a.r.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: C = None
        self.q: C = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
l = C("l")
c = C("c")
d = A("d")
m = A("m")
i = A("i")
e = B("e")
f = A("f")

a.r = g
a.o = l
a.q = l
g.v = e
l.x = e
l.r = e
l.v = c
c.x = e
c.r = e
c.v = l
d.r = e
d.o = c
d.q = c
m.r = e
m.o = c
m.q = c
i.r = g
i.o = c
i.q = l
e.v = g
f.r = e
f.o = c
f.q = l
assert a.r.v.v.v.v.v.txt == "e"