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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: A = None
        self.p: A = None
        self.txt = txt

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

h = A("h")
b = B("b")
c = C("c")
e = D("e")
j = B("j")

h.w = e
h.y = b
b.q = e
b.u = h
b.r = c
c.t = j
c.o = h
c.p = h
e.o = h
e.y = h
e.s = h
e.w = c
j.q = e
j.u = h
j.r = c
assert j.q.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: A = None
        self.p: A = None
        self.txt = txt

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

h = A("h")
b = B("b")
c = C("c")
e = D("e")
j = B("j")

h.w = e
h.y = b
b.q = e
b.u = h
b.r = c
c.t = j
c.o = h
c.p = h
e.o = h
e.y = h
e.s = h
e.w = c
j.q = e
j.u = h
j.r = c
assert j.q.o.w.txt == "e"