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

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

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

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

f = A("f")
d = B("d")
a = C("a")
i = D("i")

f.s = a
d.v = a
d.y = i
a.q = i
a.t = i
a.p = f
i.u = d
assert f.s.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
a = C("a")
i = D("i")

f.s = a
d.v = a
d.y = i
a.q = i
a.t = i
a.p = f
i.u = d
assert f.s.q.u.txt == "d"