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

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

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

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

n = A("n")
f = B("f")
c = C("c")
g = D("g")
i = C("i")
h = C("h")
k = C("k")

n.w = g
n.r = g
n.t = k
f.y = c
f.p = g
c.q = n
c.v = k
c.p = h
c.x = f
g.t = n
i.q = n
i.v = c
i.p = h
i.x = f
h.q = n
h.v = k
h.p = c
h.x = f
k.q = n
k.v = i
k.p = h
k.x = f
assert k.p.x.p.t.r.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.t: C = None
        self.r: D = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
c = C("c")
g = D("g")
i = C("i")
h = C("h")
k = C("k")

n.w = g
n.r = g
n.t = k
f.y = c
f.p = g
c.q = n
c.v = k
c.p = h
c.x = f
g.t = n
i.q = n
i.v = c
i.p = h
i.x = f
h.q = n
h.v = k
h.p = c
h.x = f
k.q = n
k.v = i
k.p = h
k.x = f
assert k.p.x.p.t.r.t.t.txt == "k"