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

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

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

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

f = A("f")
g = B("g")
e = C("e")
m = D("m")
k = A("k")
b = D("b")
c = C("c")
h = B("h")
i = D("i")
j = D("j")

f.x = e
g.p = f
g.s = m
g.v = j
g.x = i
e.t = c
e.y = h
m.p = k
k.x = e
b.p = k
c.t = e
c.y = h
h.p = k
h.s = b
h.v = j
h.x = m
i.p = f
j.p = k
assert f.x.t.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
e = C("e")
m = D("m")
k = A("k")
b = D("b")
c = C("c")
h = B("h")
i = D("i")
j = D("j")

f.x = e
g.p = f
g.s = m
g.v = j
g.x = i
e.t = c
e.y = h
m.p = k
k.x = e
b.p = k
c.t = e
c.y = h
h.p = k
h.s = b
h.v = j
h.x = m
i.p = f
j.p = k
assert f.x.t.y.s.txt == "b"