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

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

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

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

h = A("h")
b = B("b")
d = C("d")
i = D("i")
f = C("f")
l = A("l")

h.q = b
h.r = i
h.v = i
h.z = i
b.w = l
d.u = l
d.r = l
d.z = b
d.o = h
i.q = d
i.r = b
i.x = b
f.u = l
f.o = l
f.r = h
f.z = b
l.q = b
l.r = i
l.v = i
l.z = i
assert i.q.o.z.x.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: D = None
        self.v: D = None
        self.z: D = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
d = C("d")
i = D("i")
f = C("f")
l = A("l")

h.q = b
h.r = i
h.v = i
h.z = i
b.w = l
d.u = l
d.r = l
d.z = b
d.o = h
i.q = d
i.r = b
i.x = b
f.u = l
f.o = l
f.r = h
f.z = b
l.q = b
l.r = i
l.v = i
l.z = i
assert i.q.o.z.x.w.r.txt == "i"