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

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

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

b = A("b")
h = B("h")
f = C("f")
a = A("a")
g = A("g")
j = A("j")
d = A("d")
n = B("n")
c = C("c")
e = B("e")

b.p = f
b.v = j
h.v = n
h.r = e
h.s = a
f.w = c
f.q = n
a.p = f
a.v = j
g.p = f
g.v = b
j.p = f
j.v = a
d.p = f
d.v = j
n.v = h
n.r = h
n.s = b
c.w = f
c.q = e
e.v = h
e.r = h
e.s = j
assert e.s.v.p.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: A = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
f = C("f")
a = A("a")
g = A("g")
j = A("j")
d = A("d")
n = B("n")
c = C("c")
e = B("e")

b.p = f
b.v = j
h.v = n
h.r = e
h.s = a
f.w = c
f.q = n
a.p = f
a.v = j
g.p = f
g.v = b
j.p = f
j.v = a
d.p = f
d.v = j
n.v = h
n.r = h
n.s = b
c.w = f
c.q = e
e.v = h
e.r = h
e.s = j
assert e.s.v.p.q.s.txt == "b"