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

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

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

a = A("a")
c = B("c")
d = C("d")
m = B("m")
g = A("g")
j = B("j")
i = B("i")

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

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

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

a = A("a")
c = B("c")
d = C("d")
m = B("m")
g = A("g")
j = B("j")
i = B("i")

a.o = c
a.u = c
a.v = i
c.x = d
c.q = a
c.r = g
d.v = j
d.z = a
m.x = d
m.q = g
m.r = a
g.o = j
g.u = m
g.v = i
j.x = d
j.q = a
j.r = a
i.x = d
i.q = g
i.r = g
assert c.x.v.r.txt == "a"