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

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

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

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

d = A("d")
e = B("e")
j = C("j")
f = D("f")
a = A("a")

d.u = f
d.x = a
d.s = a
d.r = e
e.x = a
j.r = f
j.s = e
j.q = e
j.p = a
f.y = j
a.u = f
a.x = d
a.s = d
a.r = e
assert f.y.q.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
j = C("j")
f = D("f")
a = A("a")

d.u = f
d.x = a
d.s = a
d.r = e
e.x = a
j.r = f
j.s = e
j.q = e
j.p = a
f.y = j
a.u = f
a.x = d
a.s = d
a.r = e
assert f.y.q.x.u.txt == "f"