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

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

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

i = A("i")
b = B("b")
f = C("f")
c = B("c")
g = C("g")
n = B("n")
e = C("e")

i.q = e
i.x = f
b.u = i
b.y = i
b.x = n
f.w = c
f.v = g
f.y = i
c.u = i
c.y = i
c.x = n
g.w = n
g.v = e
g.y = i
n.u = i
n.y = i
n.x = b
e.w = n
e.v = g
e.y = i
assert n.x.y.x.v.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
f = C("f")
c = B("c")
g = C("g")
n = B("n")
e = C("e")

i.q = e
i.x = f
b.u = i
b.y = i
b.x = n
f.w = c
f.v = g
f.y = i
c.u = i
c.y = i
c.x = n
g.w = n
g.v = e
g.y = i
n.u = i
n.y = i
n.x = b
e.w = n
e.v = g
e.y = i
assert n.x.y.x.v.y.x.y.txt == "i"