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

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

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

m = A("m")
a = B("a")
j = C("j")
g = A("g")
n = C("n")
k = B("k")
h = C("h")
f = C("f")
d = A("d")
c = B("c")

m.v = a
a.u = k
a.q = k
a.p = d
j.p = h
j.u = d
g.v = k
n.p = j
n.u = m
k.u = a
k.q = c
k.p = m
h.p = f
h.u = d
f.p = h
f.u = d
d.v = a
c.u = a
c.q = k
c.p = g
assert j.p.p.p.u.v.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

m = A("m")
a = B("a")
j = C("j")
g = A("g")
n = C("n")
k = B("k")
h = C("h")
f = C("f")
d = A("d")
c = B("c")

m.v = a
a.u = k
a.q = k
a.p = d
j.p = h
j.u = d
g.v = k
n.p = j
n.u = m
k.u = a
k.q = c
k.p = m
h.p = f
h.u = d
f.p = h
f.u = d
d.v = a
c.u = a
c.q = k
c.p = g
assert j.p.p.p.u.v.p.v.p.txt == "d"