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

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

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

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

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

i.y = c
i.z = c
i.q = d
i.r = l
c.t = l
h.o = c
h.w = d
d.p = h
l.y = c
l.z = c
l.q = d
l.r = i
m.o = c
m.w = d
b.o = c
b.w = d
assert b.w.p.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.q: D = None
        self.r: A = None
        self.txt = txt

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

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

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

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

i.y = c
i.z = c
i.q = d
i.r = l
c.t = l
h.o = c
h.w = d
d.p = h
l.y = c
l.z = c
l.q = d
l.r = i
m.o = c
m.w = d
b.o = c
b.w = d
assert b.w.p.o.t.txt == "l"