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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: A = None
        self.p: B = None
        self.u: C = None
        self.txt = txt

i = A("i")
g = B("g")
h = C("h")
e = D("e")
b = B("b")

i.q = e
g.o = b
g.w = e
g.x = i
h.w = i
e.s = h
e.u = h
e.v = i
e.p = b
b.o = g
b.w = e
b.x = i
assert g.w.s.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: A = None
        self.p: B = None
        self.u: C = None
        self.txt = txt

i = A("i")
g = B("g")
h = C("h")
e = D("e")
b = B("b")

i.q = e
g.o = b
g.w = e
g.x = i
h.w = i
e.s = h
e.u = h
e.v = i
e.p = b
b.o = g
b.w = e
b.x = i
assert g.w.s.w.q.txt == "e"