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

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

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

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

i = A("i")
c = B("c")
h = C("h")
j = D("j")
a = A("a")

i.w = c
i.y = c
i.q = h
c.y = j
c.t = a
c.s = h
c.r = h
h.x = j
h.p = c
j.w = h
j.r = h
j.x = c
a.w = c
a.y = c
a.q = h
assert a.q.x.x.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

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

i = A("i")
c = B("c")
h = C("h")
j = D("j")
a = A("a")

i.w = c
i.y = c
i.q = h
c.y = j
c.t = a
c.s = h
c.r = h
h.x = j
h.p = c
j.w = h
j.r = h
j.x = c
a.w = c
a.y = c
a.q = h
assert a.q.x.x.s.p.txt == "c"