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

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

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

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

d = A("d")
c = B("c")
b = C("b")
k = D("k")
g = D("g")
a = D("a")
j = A("j")

d.y = g
d.t = c
d.u = j
c.v = g
c.t = b
b.w = j
b.v = g
k.q = a
k.y = c
k.p = c
g.q = a
g.y = c
g.p = c
a.q = k
a.y = c
a.p = c
j.y = g
j.t = c
j.u = d
assert b.w.t.v.p.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: B = None
        self.u: A = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
b = C("b")
k = D("k")
g = D("g")
a = D("a")
j = A("j")

d.y = g
d.t = c
d.u = j
c.v = g
c.t = b
b.w = j
b.v = g
k.q = a
k.y = c
k.p = c
g.q = a
g.y = c
g.p = c
a.q = k
a.y = c
a.p = c
j.y = g
j.t = c
j.u = d
assert b.w.t.v.p.v.q.txt == "a"