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

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

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

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

i = A("i")
f = B("f")
c = C("c")
a = D("a")
b = C("b")

i.q = f
i.p = c
i.t = c
i.w = c
f.q = a
f.v = a
f.p = i
f.w = i
c.x = f
c.u = b
a.p = f
b.x = f
b.u = c
assert f.w.p.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: C = None
        self.t: C = None
        self.w: C = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
c = C("c")
a = D("a")
b = C("b")

i.q = f
i.p = c
i.t = c
i.w = c
f.q = a
f.v = a
f.p = i
f.w = i
c.x = f
c.u = b
a.p = f
b.x = f
b.u = c
assert f.w.p.x.v.txt == "a"