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

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

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

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

k = A("k")
n = B("n")
b = C("b")
j = D("j")
h = C("h")
m = B("m")
e = A("e")

k.v = e
k.u = e
k.x = n
k.p = m
n.u = k
n.r = m
b.s = m
b.r = m
b.z = h
b.u = h
j.r = n
j.q = k
j.v = e
h.s = n
h.z = b
h.u = b
h.r = m
m.u = k
m.r = n
e.v = k
e.u = k
e.x = n
e.p = m
assert j.q.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: B = None
        self.p: B = None
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
b = C("b")
j = D("j")
h = C("h")
m = B("m")
e = A("e")

k.v = e
k.u = e
k.x = n
k.p = m
n.u = k
n.r = m
b.s = m
b.r = m
b.z = h
b.u = h
j.r = n
j.q = k
j.v = e
h.s = n
h.z = b
h.u = b
h.r = m
m.u = k
m.r = n
e.v = k
e.u = k
e.x = n
e.p = m
assert j.q.x.u.txt == "k"