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

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

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

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

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

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

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

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

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

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

k.r = g
n.x = m
n.p = j
a.x = j
a.t = n
a.p = m
m.q = k
m.z = g
m.x = g
m.w = a
g.x = m
g.p = j
j.x = a
j.t = n
j.p = m
assert a.x.x.x.t.p.x.txt == "a"