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

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

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

f = A("f")
n = B("n")
i = C("i")
e = A("e")
d = A("d")
c = A("c")
b = C("b")

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

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

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

f = A("f")
n = B("n")
i = C("i")
e = A("e")
d = A("d")
c = A("c")
b = C("b")

f.o = i
f.r = c
f.p = d
n.s = c
n.q = c
i.w = n
i.r = n
e.o = i
e.r = d
e.p = c
d.o = b
d.r = f
d.p = f
c.o = b
c.r = f
c.p = f
b.w = n
b.r = n
assert c.p.o.w.s.o.txt == "b"