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

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

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

l = A("l")
g = B("g")
a = C("a")
i = C("i")
n = B("n")
b = B("b")

l.p = b
l.w = b
l.u = a
g.y = i
g.x = b
a.t = i
a.p = g
a.s = g
i.t = a
i.p = g
i.s = n
n.y = a
n.x = b
b.y = a
b.x = g
assert a.t.s.y.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: B = None
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
a = C("a")
i = C("i")
n = B("n")
b = B("b")

l.p = b
l.w = b
l.u = a
g.y = i
g.x = b
a.t = i
a.p = g
a.s = g
i.t = a
i.p = g
i.s = n
n.y = a
n.x = b
b.y = a
b.x = g
assert a.t.s.y.p.x.txt == "b"