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

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

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

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

k = A("k")
f = B("f")
l = C("l")
a = D("a")
d = C("d")
i = A("i")

k.q = a
k.v = i
k.p = d
f.o = i
f.q = d
f.v = a
f.w = l
l.o = d
l.u = k
l.w = k
a.z = f
a.p = f
d.o = l
d.u = k
d.w = k
i.q = a
i.v = k
i.p = d
assert f.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
l = C("l")
a = D("a")
d = C("d")
i = A("i")

k.q = a
k.v = i
k.p = d
f.o = i
f.q = d
f.v = a
f.w = l
l.o = d
l.u = k
l.w = k
a.z = f
a.p = f
d.o = l
d.u = k
d.w = k
i.q = a
i.v = k
i.p = d
assert f.o.q.p.txt == "f"