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

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

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

i = A("i")
l = B("l")
e = C("e")
a = A("a")
g = B("g")
d = C("d")
h = B("h")
b = C("b")

i.s = d
i.x = a
i.y = a
l.z = a
l.u = d
e.q = b
e.p = i
e.x = d
a.s = b
a.x = i
a.y = i
g.z = a
g.u = d
d.q = b
d.p = a
d.x = e
h.z = i
h.u = d
b.q = e
b.p = a
b.x = d
assert e.x.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: A = None
        self.y: A = None
        self.txt = txt

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

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

i = A("i")
l = B("l")
e = C("e")
a = A("a")
g = B("g")
d = C("d")
h = B("h")
b = C("b")

i.s = d
i.x = a
i.y = a
l.z = a
l.u = d
e.q = b
e.p = i
e.x = d
a.s = b
a.x = i
a.y = i
g.z = a
g.u = d
d.q = b
d.p = a
d.x = e
h.z = i
h.u = d
b.q = e
b.p = a
b.x = d
assert e.x.p.s.p.txt == "a"