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

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

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

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

j = A("j")
m = B("m")
b = C("b")
h = D("h")
i = C("i")

j.p = b
j.w = b
j.v = h
j.q = i
m.q = j
m.y = b
b.w = h
b.r = j
b.u = j
b.q = m
h.q = m
i.w = h
i.r = j
i.u = j
i.q = m
assert i.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: D = None
        self.w: C = None
        self.q: C = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
b = C("b")
h = D("h")
i = C("i")

j.p = b
j.w = b
j.v = h
j.q = i
m.q = j
m.y = b
b.w = h
b.r = j
b.u = j
b.q = m
h.q = m
i.w = h
i.r = j
i.u = j
i.q = m
assert i.w.q.y.txt == "b"