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

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

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

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

a = A("a")
h = B("h")
i = C("i")
j = D("j")
f = B("f")
k = D("k")
b = A("b")
d = B("d")

a.s = i
h.p = j
h.r = d
i.v = f
i.s = f
i.u = d
j.t = k
j.z = k
j.u = a
j.x = d
f.p = j
f.r = d
k.t = j
k.z = j
k.u = b
k.x = f
b.s = i
d.p = k
d.r = f
assert d.r.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
i = C("i")
j = D("j")
f = B("f")
k = D("k")
b = A("b")
d = B("d")

a.s = i
h.p = j
h.r = d
i.v = f
i.s = f
i.u = d
j.t = k
j.z = k
j.u = a
j.x = d
f.p = j
f.r = d
k.t = j
k.z = j
k.u = b
k.x = f
b.s = i
d.p = k
d.r = f
assert d.r.p.x.txt == "d"