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

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

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

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

l.p = k
b.y = f
b.w = k
b.s = g
c.q = g
c.u = i
k.y = i
k.w = b
k.s = c
f.p = k
i.p = k
g.q = c
g.u = f
assert f.p.y.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

l.p = k
b.y = f
b.w = k
b.s = g
c.q = g
c.u = i
k.y = i
k.w = b
k.s = c
f.p = k
i.p = k
g.q = c
g.u = f
assert f.p.y.p.s.q.txt == "g"