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

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

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

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

k = A("k")
e = B("e")
b = C("b")
a = D("a")
g = A("g")

k.t = b
k.s = b
k.w = e
k.r = g
e.z = k
e.v = g
e.q = a
b.t = e
b.y = e
b.w = a
b.v = k
a.p = b
a.w = b
a.q = b
a.s = k
g.t = b
g.s = b
g.w = e
g.r = k
assert g.r.s.t.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: C = None
        self.w: B = None
        self.r: A = None
        self.txt = txt

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

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

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

k = A("k")
e = B("e")
b = C("b")
a = D("a")
g = A("g")

k.t = b
k.s = b
k.w = e
k.r = g
e.z = k
e.v = g
e.q = a
b.t = e
b.y = e
b.w = a
b.v = k
a.p = b
a.w = b
a.q = b
a.s = k
g.t = b
g.s = b
g.w = e
g.r = k
assert g.r.s.t.q.p.txt == "b"