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

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

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

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

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

b.s = a
d.q = b
d.u = a
e.v = b
e.q = c
a.x = i
a.v = c
i.v = b
i.q = c
c.x = i
c.v = a
assert c.x.v.s.v.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

b.s = a
d.q = b
d.u = a
e.v = b
e.q = c
a.x = i
a.v = c
i.v = b
i.q = c
c.x = i
c.v = a
assert c.x.v.s.v.v.x.txt == "i"