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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: A = None
        self.q: D = None
        self.w: D = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
c = C("c")
e = D("e")
b = B("b")
k = D("k")
l = C("l")
d = A("d")

n.x = j
n.s = l
j.z = l
j.r = d
j.q = k
j.w = k
c.x = j
c.t = b
e.p = j
e.u = c
e.q = d
b.z = l
b.r = n
b.q = k
b.w = k
k.p = b
k.u = c
k.q = d
l.x = b
l.t = j
d.x = j
d.s = c
assert n.s.x.r.x.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: A = None
        self.q: D = None
        self.w: D = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
c = C("c")
e = D("e")
b = B("b")
k = D("k")
l = C("l")
d = A("d")

n.x = j
n.s = l
j.z = l
j.r = d
j.q = k
j.w = k
c.x = j
c.t = b
e.p = j
e.u = c
e.q = d
b.z = l
b.r = n
b.q = k
b.w = k
k.p = b
k.u = c
k.q = d
l.x = b
l.t = j
d.x = j
d.s = c
assert n.s.x.r.x.q.q.txt == "d"