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

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

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

d = A("d")
k = B("k")
m = C("m")
n = B("n")
f = B("f")
c = C("c")
e = A("e")

d.s = n
d.x = e
d.w = e
k.o = f
k.u = e
m.x = f
m.v = c
m.q = c
n.o = f
n.u = d
f.o = n
f.u = d
c.x = k
c.v = m
c.q = m
e.s = k
e.x = d
e.w = d
assert c.q.v.x.o.u.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: A = None
        self.w: A = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
m = C("m")
n = B("n")
f = B("f")
c = C("c")
e = A("e")

d.s = n
d.x = e
d.w = e
k.o = f
k.u = e
m.x = f
m.v = c
m.q = c
n.o = f
n.u = d
f.o = n
f.u = d
c.x = k
c.v = m
c.q = m
e.s = k
e.x = d
e.w = d
assert c.q.v.x.o.u.x.x.txt == "d"