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

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

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

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

b = A("b")
k = B("k")
f = C("f")
i = D("i")
g = B("g")
a = A("a")
e = C("e")

b.x = f
b.z = i
b.p = e
b.w = e
k.p = i
k.y = i
k.v = e
f.r = i
i.q = k
i.w = k
g.p = i
g.y = i
g.v = e
a.x = e
a.w = e
a.z = i
a.p = f
e.r = i
assert f.r.w.v.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: D = None
        self.p: C = None
        self.w: C = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
f = C("f")
i = D("i")
g = B("g")
a = A("a")
e = C("e")

b.x = f
b.z = i
b.p = e
b.w = e
k.p = i
k.y = i
k.v = e
f.r = i
i.q = k
i.w = k
g.p = i
g.y = i
g.v = e
a.x = e
a.w = e
a.z = i
a.p = f
e.r = i
assert f.r.w.v.r.w.txt == "k"