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

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

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

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

c = A("c")
a = B("a")
h = C("h")
g = D("g")
e = D("e")

c.x = a
c.s = g
c.z = e
a.r = g
a.q = c
a.x = e
h.v = e
g.p = e
g.v = e
g.y = c
e.p = g
e.v = g
e.y = c
assert e.p.y.x.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: D = None
        self.z: D = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
h = C("h")
g = D("g")
e = D("e")

c.x = a
c.s = g
c.z = e
a.r = g
a.q = c
a.x = e
h.v = e
g.p = e
g.v = e
g.y = c
e.p = g
e.v = g
e.y = c
assert e.p.y.x.r.y.txt == "c"