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

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

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

c = A("c")
g = B("g")
f = C("f")
l = B("l")
k = A("k")
e = C("e")

c.p = g
g.q = e
g.o = e
f.w = e
l.q = f
l.o = f
k.p = g
e.w = f
assert c.p.q.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
f = C("f")
l = B("l")
k = A("k")
e = C("e")

c.p = g
g.q = e
g.o = e
f.w = e
l.q = f
l.o = f
k.p = g
e.w = f
assert c.p.q.w.w.w.w.txt == "e"