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

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

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

j = A("j")
h = B("h")
b = C("b")
k = A("k")
f = B("f")
d = C("d")
g = A("g")
m = C("m")
i = A("i")
l = C("l")

j.r = i
j.v = d
h.w = k
h.y = f
b.p = h
b.r = d
b.q = d
k.r = g
k.v = b
f.w = g
f.y = h
d.p = h
d.r = b
d.q = l
g.r = i
g.v = b
m.p = h
m.r = l
m.q = b
i.r = j
i.v = m
l.p = f
l.r = d
l.q = m
assert d.r.q.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: C = None
        self.txt = txt

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

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

j = A("j")
h = B("h")
b = C("b")
k = A("k")
f = B("f")
d = C("d")
g = A("g")
m = C("m")
i = A("i")
l = C("l")

j.r = i
j.v = d
h.w = k
h.y = f
b.p = h
b.r = d
b.q = d
k.r = g
k.v = b
f.w = g
f.y = h
d.p = h
d.r = b
d.q = l
g.r = i
g.v = b
m.p = h
m.r = l
m.q = b
i.r = j
i.v = m
l.p = f
l.r = d
l.q = m
assert d.r.q.p.w.txt == "k"