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

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.v: C = None
        self.txt = txt

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

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

d = A("d")
g = B("g")
j = C("j")
k = D("k")
a = B("a")

d.x = a
d.s = j
d.p = j
g.w = a
g.u = d
g.v = j
j.u = d
j.v = d
k.q = g
a.w = g
a.u = d
a.v = j
assert j.v.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: C = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.v: C = None
        self.txt = txt

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

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

d = A("d")
g = B("g")
j = C("j")
k = D("k")
a = B("a")

d.x = a
d.s = j
d.p = j
g.w = a
g.u = d
g.v = j
j.u = d
j.v = d
k.q = g
a.w = g
a.u = d
a.v = j
assert j.v.p.u.x.txt == "a"