class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: C = None
        self.t: D = None
        self.s: D = None
        self.txt = txt

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

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

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

j = A("j")
n = B("n")
k = C("k")
f = D("f")
l = D("l")
h = D("h")

j.u = k
j.v = k
j.t = h
j.s = f
n.x = j
k.z = j
k.q = f
k.s = n
f.x = l
f.p = n
f.v = j
f.r = h
l.x = f
l.p = n
l.v = j
l.r = h
h.x = l
h.r = l
h.p = n
h.v = j
assert j.u.q.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: C = None
        self.t: D = None
        self.s: D = None
        self.txt = txt

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

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

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

j = A("j")
n = B("n")
k = C("k")
f = D("f")
l = D("l")
h = D("h")

j.u = k
j.v = k
j.t = h
j.s = f
n.x = j
k.z = j
k.q = f
k.s = n
f.x = l
f.p = n
f.v = j
f.r = h
l.x = f
l.p = n
l.v = j
l.r = h
h.x = l
h.r = l
h.p = n
h.v = j
assert j.u.q.p.x.txt == "j"