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

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

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

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

n.x = l
n.t = l
g.u = l
l.z = n
l.y = a
l.q = a
a.z = n
a.y = l
a.q = l
b.u = l
f.u = a
assert n.t.y.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: C = None
        self.txt = txt

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

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

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

n.x = l
n.t = l
g.u = l
l.z = n
l.y = a
l.q = a
a.z = n
a.y = l
a.q = l
b.u = l
f.u = a
assert n.t.y.z.x.z.x.txt == "l"