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

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

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

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

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

n = A("n")
m = B("m")
j = C("j")
h = D("h")
g = E("g")
k = A("k")

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

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

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

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

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

n = A("n")
m = B("m")
j = C("j")
h = D("h")
g = E("g")
k = A("k")

n.r = j
n.p = j
n.x = m
m.s = j
m.q = k
m.v = g
j.s = g
j.t = m
j.z = m
h.t = n
g.x = j
k.r = j
k.p = j
k.x = m
assert j.t.s.s.x.s.txt == "g"