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

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

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

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

j = A("j")
b = B("b")
n = C("n")
h = D("h")
a = C("a")
g = A("g")

j.w = b
j.o = b
j.x = h
j.v = g
b.q = j
n.y = b
h.p = b
h.r = b
h.u = b
a.y = b
g.w = b
g.o = b
g.x = h
g.v = j
assert g.x.r.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.o: B = None
        self.v: A = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
n = C("n")
h = D("h")
a = C("a")
g = A("g")

j.w = b
j.o = b
j.x = h
j.v = g
b.q = j
n.y = b
h.p = b
h.r = b
h.u = b
a.y = b
g.w = b
g.o = b
g.x = h
g.v = j
assert g.x.r.q.w.txt == "b"