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

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

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

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

n = A("n")
a = B("a")
g = C("g")
d = D("d")
k = A("k")
i = D("i")
c = B("c")
j = C("j")
b = B("b")

n.u = b
n.q = b
n.y = g
n.x = g
a.s = k
g.v = j
g.x = c
d.s = j
d.q = g
d.p = b
k.u = c
k.y = j
k.q = a
k.x = g
i.s = j
i.q = j
i.p = c
c.s = n
j.v = g
j.x = b
b.s = k
assert j.x.s.q.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: C = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

n = A("n")
a = B("a")
g = C("g")
d = D("d")
k = A("k")
i = D("i")
c = B("c")
j = C("j")
b = B("b")

n.u = b
n.q = b
n.y = g
n.x = g
a.s = k
g.v = j
g.x = c
d.s = j
d.q = g
d.p = b
k.u = c
k.y = j
k.q = a
k.x = g
i.s = j
i.q = j
i.p = c
c.s = n
j.v = g
j.x = b
b.s = k
assert j.x.s.q.s.u.s.txt == "n"