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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

c = A("c")
i = B("i")
f = C("f")
j = D("j")
d = E("d")
g = D("g")

c.w = i
c.x = i
c.r = j
i.z = c
i.t = c
i.p = d
i.q = d
i.v = j
f.q = c
j.x = d
d.y = i
g.x = d
assert f.q.r.x.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

c = A("c")
i = B("i")
f = C("f")
j = D("j")
d = E("d")
g = D("g")

c.w = i
c.x = i
c.r = j
i.z = c
i.t = c
i.p = d
i.q = d
i.v = j
f.q = c
j.x = d
d.y = i
g.x = d
assert f.q.r.x.y.q.txt == "d"