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

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

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

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

j = A("j")
k = B("k")
l = C("l")
a = D("a")
m = A("m")
d = D("d")

j.w = k
j.q = k
j.r = l
j.y = l
k.x = l
k.w = j
l.y = k
l.v = d
a.y = k
a.q = k
a.p = l
a.r = d
m.w = k
m.q = k
m.r = l
m.y = l
d.y = k
d.q = k
d.p = l
d.r = a
assert k.w.q.x.v.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: C = None
        self.y: C = None
        self.q: B = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
l = C("l")
a = D("a")
m = A("m")
d = D("d")

j.w = k
j.q = k
j.r = l
j.y = l
k.x = l
k.w = j
l.y = k
l.v = d
a.y = k
a.q = k
a.p = l
a.r = d
m.w = k
m.q = k
m.r = l
m.y = l
d.y = k
d.q = k
d.p = l
d.r = a
assert k.w.q.x.v.y.x.txt == "l"