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

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

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

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

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

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

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

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

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