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

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

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

g = A("g")
j = B("j")
m = C("m")
f = C("f")
d = A("d")
b = A("b")
c = C("c")

g.v = c
g.t = f
j.y = g
j.q = b
j.s = m
m.u = d
m.r = c
m.p = j
f.u = d
f.r = m
f.p = j
d.v = f
d.t = m
b.v = m
b.t = c
c.u = d
c.r = f
c.p = j
assert m.u.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
m = C("m")
f = C("f")
d = A("d")
b = A("b")
c = C("c")

g.v = c
g.t = f
j.y = g
j.q = b
j.s = m
m.u = d
m.r = c
m.p = j
f.u = d
f.r = m
f.p = j
d.v = f
d.t = m
b.v = m
b.t = c
c.u = d
c.r = f
c.p = j
assert m.u.t.r.txt == "c"